applicationDidReceiveRemoteNotification
,但当应用处于前台时通知直接到达应用程序而不向最终用户显示任何警报,并且还会调用事件applicationDidReceiveRemoteNotification
:(
那么如何知道用户是否点击了通知提醒(可能是旧的)或者我们是否因为应用程序位于前台而立即收到通知?
答案 0 :(得分:1)
您可以检查这样的应用程序状态。
if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) {
// Just received notification (Foreground)
} else if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateInactive) {
// launched by taping notification
} else if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
// Just received notification (Background)
}