简体   繁体   中英

get remote push notification message in background in iOS

I have an app which need to get the message of the remote push notification in background so that when the user tap the app icon and resume/launch the app, the app can show an alert view which displays the notification message. What I plan to do is to use the function

"application:didReceiveRemoteNotification:fetchCompletionHandler:"

which will be called when the notification has arrived when the app is in background. I will first record the remote notification message in this function and then when the app is launched or resumed to foreground, I will show the alert view to display the saved message. Does anyone have the same experience?

You can do as you said. It will work. But, keep in mind that if ever the app is not in background (was quit manually by the user) the function application:didReceiveRemoteNotification:fetchCompletionHandler: will never be called. If everything is ok, you'll have to store the message in your data model. Also think of the case where multiple notifications are received before the user open the app.

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