0

I have implemented AWS SNS push notification service.

We have an issue which is explained below :

Scenario :

We are trying to save the notification message we receive as a part of requirement.

When the app is killed (swipe out from recent apps) we are able to receive notification, also we are able to save the notification message when we open the message directly from the notification panel it works fine,but when we open the app directly the notification message is not getting saved.

In short we are not able to know if we had received a notification message if we directly open the app rather than clicking the message from the notification panel.

Is this default behavior ? or is there any work around for this ?

Have looked into many posts on about Push Notifications but haven't seen any threads pointing to this scenario.

2
  • Yeah! it is default behaviour... I don't think there is a work around
    – sargeras
    Commented Oct 14, 2015 at 13:33
  • @sargeras Thanks, but i see that what app automatically sync the messages from we open the app, any idea how they might be doing it ?
    – Brjv
    Commented Oct 14, 2015 at 13:35

2 Answers 2

2

This is a normal behavior, and there is no workaround.
If your app is killed by the user, it won't be able to run ANY code before it's manually launched again.
If it's manually launched from a notification, this notification's payload will be handled by your AppDelegate.

On top of that, don't forget that Push notifications are Best Effort. That means that they are not reliable, they can be heavily delayed or never delivered at all. Don't rely on Push notifications to achieve any critical work.

If you need to keep a copy of your notifications in-app, keep them server side and fetch them as you would do with any other object.

3
  • Thanks, but i see that what app automatically sync the messages from we open the app, so are they running any service when the app opens to load the messages?
    – Brjv
    Commented Oct 14, 2015 at 13:34
  • Of course, when you open whatsapp, they call their API to get your messages (actually It's more likely to be a socket connection). But Push notifs are only convenience and don't play any critical role at all here. Commented Oct 14, 2015 at 13:35
  • @QuentinHayot It means when app is killed and we have received 10 notification, that show in notification center, but when we launch app all the notification will be remove and we don't get any notification from OS, We have to develop api to list. Please make me corrent if I am wrong. Commented Feb 8, 2017 at 11:13
0

In order to execute code when the app is killed by the user you need to implement VOIP using PushKit framework provided by apple.

VOIP push unlike regular push notification enables the app to become active even if the app is killed by user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.