Push Notification + app not running

5 posts, 1 answers
  1. Dan
    Dan avatar
    26 posts
    Member since:
    Oct 2013

    Posted 14 Aug 2014 Link to this post

    I have push notifications installed and running on android and iOs.  Everything is working fine.

    When I send a notification while the app is not running how can I get that information to the device?

    Put another way: on app start, how can I tell if a notification was delivered since the app was shut down?

    Thanks,
    Dan
  2. Dan
    Dan avatar
    26 posts
    Member since:
    Oct 2013

    Posted 14 Aug 2014 Link to this post

    One more detail: if I click on the notification message, it launches the app and I get the message.  If I launch the app from the icon (with a badge present), the app does not get the notification message.
  3. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 14 Aug 2014 Link to this post

    Hi Dan,

    As to your questions:

    Q: When I send a notification while the app is not running how can I get that information to the device?
    A:
    The information about all notifications received while the app wasn't running will be available to the device. However, when the notification is received and the app is launched by the user you need to invoke again the device.enableNotifications() method and if it is successfully completed the information in each notification will be dispatched to the app (the onPushReceivedCallback will be invoked).
    There is no means to access the information before the above is executed.

    More about the workflow on a device can be read here.

    You will receive the state (foreground/background) of the app in the arguments passed to the callback (args.foreground). This may be useful for the logic of your app. Android also has a 'coldstart' state as explained here.

    Q: On app start, how can I tell if a notification was delivered since the app was shut down?
    A:
    The notification will be delivered while the app is not running and will be placed in the notification tray in Android. In iOS this depends on the user's settings - mostly the notifications will be received in the form of a banner/alert when the app is not running or in the background. If the phone is on standby it will be shown in the notification center on the lock screen (still depends on the user's settings).

    Q: If I click on the notification message, it launches the app and I get the message.  If I launch the app from the icon (with a badge present), the app does not get the notification message.
    A:
    I assume that you refer to the workflow in iOS. This is the behavior in iOS as designed by Apple.

    Please, let me know if you have further questions.


    Regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  4. Dan
    Dan avatar
    26 posts
    Member since:
    Oct 2013

    Posted 14 Aug 2014 Link to this post

    Q: If I click on the notification message, it launches the app and I get the message.  If I launch the app from the icon (with a badge present), the app does not get the notification message.
    A: I assume that you refer to the workflow in iOS. This is the behavior in iOS as designed by Apple.

    So if a user clicks on the app icon (with badge) and NOT the notification alert in the system tray then there is no way for the app to know a notification was delivered? 
  5. Answer
    Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 15 Aug 2014 Link to this post

    Hello Dan,

    Yes, that is the behavior in iOS - if a user clicks on the app icon (with badge) and not the notification alert in the system tray this will launch the app but the event that a notification was received will not be emitted.

    When a push notification is received the notification object is dispatched to the app in the following two cases:

    1. The application is in the foreground.
    2. The application is not in the foreground but the user launches the app by tapping the alert or the banner.

    You can read more about the logic working under the hood in this article from the official Apple documentation: Handling Local and Remote Notifications.

    Please, let me know if this answers your question.

    Best regards,
    Anton Dobrev
    Telerik
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
Back to Top