我正在处理推送通知流程,但没有准确地知道如何处理它。我需要一个简单的解释,当推送通知到来时,该委托被称为
我无法维持我的应用程序申请状态,对我来说,流程应该是这样的:
如何在Xcode 8.1 / iOS 10.1.1中实现这一目标?
我也使用后台模式远程通知和后台提取。
答案 0 :(得分:1)
在AppDelegate.m中用它来检查用户点按图标的位置
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//Handle notification when the user click it while app is running in background or foreground.
if(application.applicationState == UIApplicationStateInactive) {
NSLog(@"Inactive - the user has tapped in the notification when app was closed or in background");
//do some tasks
}
else if (application.applicationState == UIApplicationStateBackground) {
NSLog(@"application Background - notification has arrived when app was in background");
}
else {
NSLog(@"application Active - notication has arrived while app was opened");
//do tasks
}
}
答案 1 :(得分:0)
当推送通知从服务器发送应用程序端的委托调用时,您必须通过添加registerForPushNotifications从应用程序端注册。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
//Handle notification when the user click it while app is running in background or foreground.
//Where userinfo is a dict. It has the data sent from server
}