Description
I am unable to receive browser notifications from a UserScript (using Notification.requestPermission() and new Notification()) on sboportal.org.in in an Android environment. The browser never displays the standard notification permission prompt, and there is no option within the browser's site settings to manually grant notification permission for this domain.
Context:
- UserScript Manager: [Specify your UserScript Manager, e.g., Tampermonkey, Violentmonkey. If you don't know, state "Unspecified UserScript Manager (running on Android)"]
- Browser: [Specify the browser you are using, e.g., Kiwi Browser, Firefox Nightly, or simply "A cloned Android browser app"].
- Operating System: Android [Specify Android version if known, e.g., Android 11].
- Specific Website: https://sboportal.org.in/
- Key Detail: I am using an App Cloner to run the browser app.
Steps to Reproduce: - Install the provided UserScript (see "Relevant Code Snippet" below) in the specified UserScript Manager.
- Ensure that the Android OS-level notification permission for the cloned browser app is enabled in the device settings. (Screenshot available, confirming this).
- Navigate to https://sboportal.org.in/ in the cloned browser app.
- Observe: A UserScript-injected "Test Notification" button appears on the top right, and a "UserScript Logs" box appears at the bottom left.
- Observe (Initial Prompt): No standard browser notification permission prompt appears automatically when the page loads.
- Click the "Test Notification" button.
- Observe: No browser notification appears. No notification permission prompt appears after clicking the button.
- Check the browser's internal "Site settings" or "Notifications" settings for sboportal.org.in. Observe: There is no entry or option to manually allow/block notifications for this specific domain.
Expected Behavior: - Upon visiting sboportal.org.in, the browser should display a prompt asking for permission to send notifications (triggered by Notification.requestPermission()).
- If permission is granted by the user, subsequent calls to new Notification() should display browser notifications.
- The browser's site settings should provide an option to manually manage notification permissions for visited websites.
Actual Behavior: - The browser never displays a notification permission prompt for sboportal.org.in, either automatically on page load or after clicking the "Test Notification" button.
- There is no manual option within the browser's site settings to grant notification permission for sboportal.org.in.
- Consequently, no browser notifications are displayed.
Relevant Code Snippet (Test Script):
// ==UserScript==
// @name SBO Android Notification Test (Click Debug)
// @namespace http://tamilscript.local/
// @Version 1.3
// @description Tests browser notifications and displays logs in a copyable box, with added click event debugging for Android.
// @match https://sboportal.org.in/*
// @grant Notification
// ==/UserScript==
(function() {
'use strict';
// Log box creation (omitted for brevity in this text, but is part of the actual script)
function createLogBox() { /* ... full function from previous response ... */ }
function requestAndTestNotificationPermission() {
console.log('Attempting to request/test Notification Permission...');
if (Notification.permission === 'granted') {
console.log('Notification permission already granted.');
new Notification('SBO Notification Test', { body: 'Permission already granted. Click the button to test!', icon: 'https://sboportal.org.in/favicon.ico' });
} else if (Notification.permission !== 'denied') {
Notification.requestPermission().then(permission => {
console.log('Notification Permission Status:', permission); // This log is never hit.
if (permission === 'granted') {
new Notification('SBO Notification Test', { body: 'Permission granted! Click the button to test!', icon: 'https://sboportal.org.in/favicon.ico' });
} else {
console.warn('Notification permission was denied by user or browser.');
}
});
} else {
console.error('Notification permission permanently denied. Please enable in browser settings.');
}
}
function sendTestNotification() {
console.log('--- sendTestNotification function called ---');
if (Notification.permission === 'granted') {
new Notification('SBO Test Notification', { body: 'This is a test notification from the button!', icon: 'https://sboportal.org.in/favicon.ico', tag: 'sbo-test-notification' });
console.log('Test Notification sent from button.');
} else {
console.warn('Notification permission not granted when button was clicked. Trying to request permission...');
requestAndTestNotificationPermission();
}
}
function createTestButton() {
const button = document.createElement('button');
button.textContent = 'Test Notification';
button.style.position = 'fixed'; button.style.top = '10px'; button.style.right = '10px';
button.style.zIndex = '99999'; button.style.padding = '8px 12px';
button.style.backgroundColor = '#4CAF50'; button.style.color = 'white';
button.style.border = 'none'; button.style.borderRadius = '5px';
button.style.cursor = 'pointer'; button.style.fontSize = '14px';
button.addEventListener('click', () => {
console.log('Button clicked! Now attempting to send notification...');
sendTestNotification();
});
function appendButton() {
if (document.body) {
document.body.appendChild(button);
console.log('Test Notification button added to DOM.');
} else {
console.log('Document body not yet available for button, retrying...');
setTimeout(appendButton, 100);
}
}
appendButton();
}
console.log('SBO Android Notification Test (Click Debug) script running.');
createLogBox();
createTestButton();
requestAndTestNotificationPermission();
})();
Logs (after page load and button click):
[1:49:53 PM] Log box created and console logs redirected.
[1:49:53 PM] Test Notification button added to DOM.
[1:49:53 PM] Attempting to request/test Notification Permission...
[1:49:54 PM] Button clicked! Now attempting to send notification...
[1:49:54 PM] --- sendTestNotification function called ---
(Note: The log Notification Permission Status: is never printed, indicating the Promise from Notification.requestPermission() is either never resolving or resolving to a state that doesn't trigger a log, but most likely the prompt itself is not shown.)
Screenshots:
(Attach screenshots of the "Test Notification" button visible on sboportal.org.in and the Android OS-level notification settings for the cloned browser app, confirming notifications are enabled at the OS level.)
Troubleshooting Attempted:
- Confirmed Android OS-level notification permission is enabled for the cloned browser app.
- Used a UserScript with debug logs to confirm script execution and button click events.
- The script confirms the button is added to the DOM and the click event listener is firing correctly.
- Browser cache and data for sboportal.org.in were cleared.
- Ensured only this test script was enabled to rule out conflicts.