对于任何条件,检查用户是否已经选定,或应用程序在后台或处于活动状态。 你只需要检查
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
if(application.applicationState == UIApplicationStateActive) {
//app is currently active, can update badges count here
}else if(application.applicationState == UIApplicationStateBackground){
//app is in background, if content-available key of your notification is set to 1, poll to your backend to retrieve data and update your interface here
}else if(application.applicationState == UIApplicationStateInactive){
//app is transitioning from background to foreground (user taps notification), do what you need when user taps here
}
你不能这样做。 – Avi
如果通知仍在通知中心,那么您将在didFinishLaunching方法中得到它 –
您应该创建一种方法来查询服务器以查看它是否有未决的通知 – jcesarmobile