简体   繁体   中英

Notify the app about remote push notification when the app is not running (terminated)

When app is not running (terminated NOT in background) and a remote push notifications is received, is there any way to inform the app about it so that the app can update something locally such as simple int counter?

I want to store something so that when the app is launched the next time, app knows that notification was received when app wasn't running and something needs to be done.

If user launches an app by tapping on a notification, obviously the app is notified about it through AppDelegate methods but these methods are never called if user launches an app by tapping on the app's icon.

To be aware of notification when user launches app by tapping on icon, i need some way to let app know that notification was received when app was in background.

There is no way you can achieve this with simple push notifications.

According to apple docs if the user has manually killed your application by swiping it out of memory, your app will never be started in the background to process data until after the user chooses to launch it again.

One solution to this problem is using VOIP push. According to apple docs -

Your app is automatically relaunched if it's not running when a VoIP push is received.

But you need a strong reason for using it and apple may ask that before approving your app on the app store.

To read more about VOIP push please go through this doc - https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html

You can also be used the "Silent Push Notifications".Which are confirming that their is something available on the server, which you need to download to your app,The payload format of the Silent push notification is like

{ content-available:1 }

The Best part of the silent notification is that they do not notify the iPhone user

Here 1 is for their is something available to download from the server.

here below i have attached the apple's silent notification slide. 在此处输入图片说明

Your App is getting Refresh in the Background.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM