Handle Push Notification when the App is off, or w

2019-09-19 14:25发布

问题:

I'm building a Push Notification platform with Amazon SNS, using Amazon Cognito and other Amazon AWS tools, so far working flawlessly.

But my App is multi-language, so I'm trying to send just 1 single push message with a dictionary within the payload, this dictionary will contain an array with all the languages that I'm supporting.

So I just don't want to simply handle the message, what I'm intending is to do not show the push message at all before selecting the proper language that should appear to the user... With the App killed or not.

So my Q:

  1. Is this seems possible?

  2. What approach do you suggest to achieve this?

Thank you all very much.

回答1:

  1. No (when the user kills the app or when backgroundfetching is turned off, no notifications will reach your app).

  2. Look into how to localize pushnotifications on apple's developer website. You can acieve exactly what you want by letting the system do the localization. See the applicable keys in the push payload: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html



回答2:

There are some limitations of APNS as follows:

  1. didReceiveRemoteNotifications delegate execute only if the application is in either foreground or background.

  2. If the application is terminated/suspended by either user or OS then notification will be displayed in notification centre but the respective delegate would not get called.

  3. Set both Background fetch and Remote notifications enabled in Background modes from project setting.

  4. Use application:didReceiveRemoteNotification:fetchCompletionHandler: delegate instead of didReceiveRemoteNotifications.

Hope this will help you.