This is a migrated thread and some comments may be shown as answers.

Push Notification + app not running

4 Answers 216 Views
Push Notifications
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dan
Top achievements
Rank 1
Dan asked on 14 Aug 2014, 01:45 PM
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

4 Answers, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 14 Aug 2014, 01:54 PM
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.
0
Anton Dobrev
Telerik team
answered on 14 Aug 2014, 04:19 PM
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.
 
0
Dan
Top achievements
Rank 1
answered on 14 Aug 2014, 04:44 PM
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? 
0
Accepted
Anton Dobrev
Telerik team
answered on 15 Aug 2014, 11:49 AM
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.
 
Tags
Push Notifications
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Anton Dobrev
Telerik team
Share this question
or