Can i use firebase cloud messaging without notification permission? (Javascript)












1















Update: Google Bug Report Description



(as suggested by google dev advocate in comments on answer 1, filed a bug report; updating the content here since it more succinctly and precisely describes the problem)



I do not need or want to show any notifications to my user. And many users are not willing to give notifications permission because they assume they will start seeing notifications.



But I wish to push data to my web page from the server. The web page is active and in the foreground. This is the classic use case that Web Sockets were designed for.



I understand that I could write my own web socket server and somehow try to scale it, or go to some other third-party for an outsourced scalable web socket push solution.



But, isn't this is a very common "sub-use-case" of the messaging that Firebase Messaging is targeted towards? Therefore shouldn't Google support this use case? I can't see any fundamental technical show-stoppers, but since Google is so smart, please do enlighten me if I am missing something on why this cannot or should not be done.



Original StackOverflow Question Text:



I don't need background notifications or service workers. All I want is to send data to the web page when it is currently loaded and in the foreground.



Websockets do not need any permission but they need a websocket server and maintenance. It is difficult or expensive to scale it.



Firebase solves the problem fundamentally but I don't see why it must require a user to give notifications permission even though I only want to push data when the page is loaded; not in the background.










share|improve this question





























    1















    Update: Google Bug Report Description



    (as suggested by google dev advocate in comments on answer 1, filed a bug report; updating the content here since it more succinctly and precisely describes the problem)



    I do not need or want to show any notifications to my user. And many users are not willing to give notifications permission because they assume they will start seeing notifications.



    But I wish to push data to my web page from the server. The web page is active and in the foreground. This is the classic use case that Web Sockets were designed for.



    I understand that I could write my own web socket server and somehow try to scale it, or go to some other third-party for an outsourced scalable web socket push solution.



    But, isn't this is a very common "sub-use-case" of the messaging that Firebase Messaging is targeted towards? Therefore shouldn't Google support this use case? I can't see any fundamental technical show-stoppers, but since Google is so smart, please do enlighten me if I am missing something on why this cannot or should not be done.



    Original StackOverflow Question Text:



    I don't need background notifications or service workers. All I want is to send data to the web page when it is currently loaded and in the foreground.



    Websockets do not need any permission but they need a websocket server and maintenance. It is difficult or expensive to scale it.



    Firebase solves the problem fundamentally but I don't see why it must require a user to give notifications permission even though I only want to push data when the page is loaded; not in the background.










    share|improve this question



























      1












      1








      1








      Update: Google Bug Report Description



      (as suggested by google dev advocate in comments on answer 1, filed a bug report; updating the content here since it more succinctly and precisely describes the problem)



      I do not need or want to show any notifications to my user. And many users are not willing to give notifications permission because they assume they will start seeing notifications.



      But I wish to push data to my web page from the server. The web page is active and in the foreground. This is the classic use case that Web Sockets were designed for.



      I understand that I could write my own web socket server and somehow try to scale it, or go to some other third-party for an outsourced scalable web socket push solution.



      But, isn't this is a very common "sub-use-case" of the messaging that Firebase Messaging is targeted towards? Therefore shouldn't Google support this use case? I can't see any fundamental technical show-stoppers, but since Google is so smart, please do enlighten me if I am missing something on why this cannot or should not be done.



      Original StackOverflow Question Text:



      I don't need background notifications or service workers. All I want is to send data to the web page when it is currently loaded and in the foreground.



      Websockets do not need any permission but they need a websocket server and maintenance. It is difficult or expensive to scale it.



      Firebase solves the problem fundamentally but I don't see why it must require a user to give notifications permission even though I only want to push data when the page is loaded; not in the background.










      share|improve this question
















      Update: Google Bug Report Description



      (as suggested by google dev advocate in comments on answer 1, filed a bug report; updating the content here since it more succinctly and precisely describes the problem)



      I do not need or want to show any notifications to my user. And many users are not willing to give notifications permission because they assume they will start seeing notifications.



      But I wish to push data to my web page from the server. The web page is active and in the foreground. This is the classic use case that Web Sockets were designed for.



      I understand that I could write my own web socket server and somehow try to scale it, or go to some other third-party for an outsourced scalable web socket push solution.



      But, isn't this is a very common "sub-use-case" of the messaging that Firebase Messaging is targeted towards? Therefore shouldn't Google support this use case? I can't see any fundamental technical show-stoppers, but since Google is so smart, please do enlighten me if I am missing something on why this cannot or should not be done.



      Original StackOverflow Question Text:



      I don't need background notifications or service workers. All I want is to send data to the web page when it is currently loaded and in the foreground.



      Websockets do not need any permission but they need a websocket server and maintenance. It is difficult or expensive to scale it.



      Firebase solves the problem fundamentally but I don't see why it must require a user to give notifications permission even though I only want to push data when the page is loaded; not in the background.







      firebase websocket firebase-cloud-messaging






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 3:25







      user2297550

















      asked Nov 21 '18 at 0:50









      user2297550user2297550

      189414




      189414
























          2 Answers
          2






          active

          oldest

          votes


















          2














          It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.



          Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.






          share|improve this answer
























          • It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

            – user2297550
            Nov 21 '18 at 1:23








          • 1





            Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

            – Doug Stevenson
            Nov 21 '18 at 1:40






          • 1





            Yes, that's what I'm hoping will happen from your contact with support.

            – Doug Stevenson
            Nov 21 '18 at 3:31






          • 1





            I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

            – Doug Stevenson
            Nov 21 '18 at 3:32








          • 1





            One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

            – Arthur Thompson
            Nov 21 '18 at 4:29



















          0














          The problem is that Firebase Messaging is only using 1 method to deliver notifications. That is the Push API specification spec, and that specification (wrongly and unfortunately) does not allow a service worker to receive messages without the user allowing an unrelated permission to show notifications.



          The fix would be for the Firebase Messaging team to provide a different way to deliver messages to active web pages -- long polling, or websockets.



          But it would be extra work for them, and may be not enough people are requesting it.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403792%2fcan-i-use-firebase-cloud-messaging-without-notification-permission-javascript%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2














            It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.



            Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.






            share|improve this answer
























            • It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

              – user2297550
              Nov 21 '18 at 1:23








            • 1





              Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

              – Doug Stevenson
              Nov 21 '18 at 1:40






            • 1





              Yes, that's what I'm hoping will happen from your contact with support.

              – Doug Stevenson
              Nov 21 '18 at 3:31






            • 1





              I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

              – Doug Stevenson
              Nov 21 '18 at 3:32








            • 1





              One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

              – Arthur Thompson
              Nov 21 '18 at 4:29
















            2














            It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.



            Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.






            share|improve this answer
























            • It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

              – user2297550
              Nov 21 '18 at 1:23








            • 1





              Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

              – Doug Stevenson
              Nov 21 '18 at 1:40






            • 1





              Yes, that's what I'm hoping will happen from your contact with support.

              – Doug Stevenson
              Nov 21 '18 at 3:31






            • 1





              I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

              – Doug Stevenson
              Nov 21 '18 at 3:32








            • 1





              One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

              – Arthur Thompson
              Nov 21 '18 at 4:29














            2












            2








            2







            It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.



            Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.






            share|improve this answer













            It's to protect the user's preferences about what your app is allowed to do. The way push messaging works on browsers is by using a service worker. Even though you say you don't need a service worker, you are actually making using of it when using Firebase Cloud Messaging in your app.



            Given that, the prompt is necessary because the browser doesn't know what you intend to do with that push message. If the user doesn't trust your app, they should have the right to limit what it can actually do, especially when they're not using your app. Mobile operating systems (iOS, Android) are the same way.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 21 '18 at 1:03









            Doug StevensonDoug Stevenson

            78.6k994112




            78.6k994112













            • It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

              – user2297550
              Nov 21 '18 at 1:23








            • 1





              Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

              – Doug Stevenson
              Nov 21 '18 at 1:40






            • 1





              Yes, that's what I'm hoping will happen from your contact with support.

              – Doug Stevenson
              Nov 21 '18 at 3:31






            • 1





              I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

              – Doug Stevenson
              Nov 21 '18 at 3:32








            • 1





              One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

              – Arthur Thompson
              Nov 21 '18 at 4:29



















            • It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

              – user2297550
              Nov 21 '18 at 1:23








            • 1





              Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

              – Doug Stevenson
              Nov 21 '18 at 1:40






            • 1





              Yes, that's what I'm hoping will happen from your contact with support.

              – Doug Stevenson
              Nov 21 '18 at 3:31






            • 1





              I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

              – Doug Stevenson
              Nov 21 '18 at 3:32








            • 1





              One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

              – Arthur Thompson
              Nov 21 '18 at 4:29

















            It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

            – user2297550
            Nov 21 '18 at 1:23







            It seems the notifications permission should come into play only when my code tries to show a notification. If a service worker consumes messages without doing anything with them that should not require notifications permission.

            – user2297550
            Nov 21 '18 at 1:23






            1




            1





            Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

            – Doug Stevenson
            Nov 21 '18 at 1:40





            Feel free to file a bug report if you think it's doing the wrong thing. firebase.google.com/support/contact/bugs-features

            – Doug Stevenson
            Nov 21 '18 at 1:40




            1




            1





            Yes, that's what I'm hoping will happen from your contact with support.

            – Doug Stevenson
            Nov 21 '18 at 3:31





            Yes, that's what I'm hoping will happen from your contact with support.

            – Doug Stevenson
            Nov 21 '18 at 3:31




            1




            1





            I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

            – Doug Stevenson
            Nov 21 '18 at 3:32







            I'm guessing the browser's logic is that if you intend to receive push messages, it assumes that you may also attempt to show a visible notification, but it can't know for sure, so it just covers the base.

            – Doug Stevenson
            Nov 21 '18 at 3:32






            1




            1





            One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

            – Arthur Thompson
            Nov 21 '18 at 4:29





            One option is to use Firebase Real-time Database or Cloud Firestore as the message delivery system. Since you don't need background messaging just write to the database and your foregrounded app will get the update.

            – Arthur Thompson
            Nov 21 '18 at 4:29













            0














            The problem is that Firebase Messaging is only using 1 method to deliver notifications. That is the Push API specification spec, and that specification (wrongly and unfortunately) does not allow a service worker to receive messages without the user allowing an unrelated permission to show notifications.



            The fix would be for the Firebase Messaging team to provide a different way to deliver messages to active web pages -- long polling, or websockets.



            But it would be extra work for them, and may be not enough people are requesting it.






            share|improve this answer






























              0














              The problem is that Firebase Messaging is only using 1 method to deliver notifications. That is the Push API specification spec, and that specification (wrongly and unfortunately) does not allow a service worker to receive messages without the user allowing an unrelated permission to show notifications.



              The fix would be for the Firebase Messaging team to provide a different way to deliver messages to active web pages -- long polling, or websockets.



              But it would be extra work for them, and may be not enough people are requesting it.






              share|improve this answer




























                0












                0








                0







                The problem is that Firebase Messaging is only using 1 method to deliver notifications. That is the Push API specification spec, and that specification (wrongly and unfortunately) does not allow a service worker to receive messages without the user allowing an unrelated permission to show notifications.



                The fix would be for the Firebase Messaging team to provide a different way to deliver messages to active web pages -- long polling, or websockets.



                But it would be extra work for them, and may be not enough people are requesting it.






                share|improve this answer















                The problem is that Firebase Messaging is only using 1 method to deliver notifications. That is the Push API specification spec, and that specification (wrongly and unfortunately) does not allow a service worker to receive messages without the user allowing an unrelated permission to show notifications.



                The fix would be for the Firebase Messaging team to provide a different way to deliver messages to active web pages -- long polling, or websockets.



                But it would be extra work for them, and may be not enough people are requesting it.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 25 '18 at 8:43

























                answered Nov 21 '18 at 13:44









                user2297550user2297550

                189414




                189414






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403792%2fcan-i-use-firebase-cloud-messaging-without-notification-permission-javascript%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to send String Array data to Server using php in android

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Is anime1.com a legal site for watching anime?