How can I receive the result of sending a notification to the notification bar?









up vote
0
down vote

favorite












Is there any way to know the result of the notification that we have sent using NotificationManager ?



Recently, I found an issue with my notifications because I was not using Android 8.0 channels, so many users were not receiving them: https://developer.android.com/training/notify-user/channels



However, I didn't realize the issue until I saw it myself in my phone.



Also, I am using Google Analytics to track how many users are receiving notifications. However, I couldn't see the issue this way (I has having a lot of false positives).



The code is very simple and looks like this:



private void sendNotification(int id, String title, String message, int color) 

if (userWantsToReceiveThisNotification)
Notification notification = buildNotification(); // This method now also creates a Notification Channel
notificationManager.notify(id, notification);
sendAnalyticsEvent();





What I am looking for is some kind of result to the notify action, as it may succeed, or not, depending on user config, app config from settings, or even a wrong setup (which was my case).



What I am expecting is something like



boolean success = notificationManger.notify(id, notification);



or



notificationManger.notify(id, notification, callbackTellingSuccess);



so I can track correctly the amount of users that actually received the notification.



Thank you very much.










share|improve this question

























    up vote
    0
    down vote

    favorite












    Is there any way to know the result of the notification that we have sent using NotificationManager ?



    Recently, I found an issue with my notifications because I was not using Android 8.0 channels, so many users were not receiving them: https://developer.android.com/training/notify-user/channels



    However, I didn't realize the issue until I saw it myself in my phone.



    Also, I am using Google Analytics to track how many users are receiving notifications. However, I couldn't see the issue this way (I has having a lot of false positives).



    The code is very simple and looks like this:



    private void sendNotification(int id, String title, String message, int color) 

    if (userWantsToReceiveThisNotification)
    Notification notification = buildNotification(); // This method now also creates a Notification Channel
    notificationManager.notify(id, notification);
    sendAnalyticsEvent();





    What I am looking for is some kind of result to the notify action, as it may succeed, or not, depending on user config, app config from settings, or even a wrong setup (which was my case).



    What I am expecting is something like



    boolean success = notificationManger.notify(id, notification);



    or



    notificationManger.notify(id, notification, callbackTellingSuccess);



    so I can track correctly the amount of users that actually received the notification.



    Thank you very much.










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Is there any way to know the result of the notification that we have sent using NotificationManager ?



      Recently, I found an issue with my notifications because I was not using Android 8.0 channels, so many users were not receiving them: https://developer.android.com/training/notify-user/channels



      However, I didn't realize the issue until I saw it myself in my phone.



      Also, I am using Google Analytics to track how many users are receiving notifications. However, I couldn't see the issue this way (I has having a lot of false positives).



      The code is very simple and looks like this:



      private void sendNotification(int id, String title, String message, int color) 

      if (userWantsToReceiveThisNotification)
      Notification notification = buildNotification(); // This method now also creates a Notification Channel
      notificationManager.notify(id, notification);
      sendAnalyticsEvent();





      What I am looking for is some kind of result to the notify action, as it may succeed, or not, depending on user config, app config from settings, or even a wrong setup (which was my case).



      What I am expecting is something like



      boolean success = notificationManger.notify(id, notification);



      or



      notificationManger.notify(id, notification, callbackTellingSuccess);



      so I can track correctly the amount of users that actually received the notification.



      Thank you very much.










      share|improve this question













      Is there any way to know the result of the notification that we have sent using NotificationManager ?



      Recently, I found an issue with my notifications because I was not using Android 8.0 channels, so many users were not receiving them: https://developer.android.com/training/notify-user/channels



      However, I didn't realize the issue until I saw it myself in my phone.



      Also, I am using Google Analytics to track how many users are receiving notifications. However, I couldn't see the issue this way (I has having a lot of false positives).



      The code is very simple and looks like this:



      private void sendNotification(int id, String title, String message, int color) 

      if (userWantsToReceiveThisNotification)
      Notification notification = buildNotification(); // This method now also creates a Notification Channel
      notificationManager.notify(id, notification);
      sendAnalyticsEvent();





      What I am looking for is some kind of result to the notify action, as it may succeed, or not, depending on user config, app config from settings, or even a wrong setup (which was my case).



      What I am expecting is something like



      boolean success = notificationManger.notify(id, notification);



      or



      notificationManger.notify(id, notification, callbackTellingSuccess);



      so I can track correctly the amount of users that actually received the notification.



      Thank you very much.







      android notifications notify notificationmanager






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 10:32









      Javier Delgado

      8621719




      8621719



























          active

          oldest

          votes











          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',
          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%2f53238073%2fhow-can-i-receive-the-result-of-sending-a-notification-to-the-notification-bar%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238073%2fhow-can-i-receive-the-result-of-sending-a-notification-to-the-notification-bar%23new-answer', 'question_page');

          );

          Post as a guest














































































          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto