79121116

Date: 2024-10-24 08:55:27
Score: 0.5
Natty:
Report link

I face the same problem, I fixed it by set click listener to call the function.

    $(document).on('touchend click', function() {
                requestNotificationPermission();
                // Remove the event listener after the permission is requested
                $(document).off('touchend click');
            });
    function requestNotificationPermission(){
                firebase.initializeApp(config);
                if (firebase.messaging.isSupported()){
                    const messaging = firebase.messaging();
    
                    messaging
                    .requestPermission()
                    .then(() => {
                        message.innerHTML = "Notifications allowed";
                        return messaging.getToken();
Reasons:
  • Whitelisted phrase (-2): I fixed
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I face the same problem
  • Low reputation (1):
Posted by: Tim Hee Wong