我构建并启用了后台模式的应用,并且应用获取的推送通知有效负载具有“内容可用”密钥。
此设置会导致didReceiveRemoteNotification
被称为每次该应用获得推送通知,这意味着如果我在应用处于后台时获得3次推送通知 - 该功能将触发3次,当应用程序applicationDidBecomeActive
我最大的问题是没有办法知道用户是否点按了 推送系统提醒 或点按了应用图标以从后台启用应用,对于用户的操作,didReceiveRemoteNotification
将触发。
有没有办法确定用户是否点击了Sys警报?
并且:http://samwize.com/2015/08/07/how-to-handle-remote-notification-with-background-mode-enabled/ 和其他答案 似乎没有帮助
答案 0 :(得分:-1)
For app is background push
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground )
{
//opened from a push notification when the app was on background
}
}
For app is terminate state
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (launchOptions != nil) {
// Launched from push notification
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
}
}