您好,我正在使用 Apple APNS 发送 RemoteNotification。我发现的问题是:
首先我想接收RemoteNotification然后跳转到其他页面,不是主页面(第一页)我的代码:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(@"remote notification: %@",[userInfo description]);
NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
NSString *alert = [apsInfo objectForKey:@"alert"];
NSLog(@"Received Push Alert: %@", alert);
NSString *sound = [apsInfo objectForKey:@"sound"];
NSLog(@"Received Push Sound: %@", sound);
NSString *badge = [apsInfo objectForKey:@"badge"];
NSLog(@"Received Push Badge: %@", badge);
application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
if ([userInfo objectForKey:@"type"])
{
NSString *nsType = [userInfo objectForKey:@"type"];
NSLog(@"Received Push nsType: %@", nsType);
if([[userInfo objectForKey:@"type"] intValue]==1){//chat
[self JumpChatHistoryView];
}else{
[self JumpMessageDetailView];
}
}
application.applicationIconBadgeNumber = 0;
}
我的应用程序进入后台并没有被系统杀死,当收到 RemoteNotification 并点击它时,我的代码没问题,它可以跳转其他 View 。但是当我杀死我的应用程序时,当我收到 RemoteNotification 时,我点击它,它没有跳过其他 View ,它只进入主视图,如何解决。
此外,当我取消 LocalNotification 时,我可以使用 [[UIApplication sharedApplication] cancelLocalNotification:notification];
但在 RemoteNotification 中我找不到相同的方法。我该怎么做?
最佳答案
你必须用这个方法在 AppDelegate.m 文件中编写你的代码:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"%@", userInfo);
NSString *notiText = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
[self JumpChatHistoryView];
}
关于iphone - 当收到 RemoteNotification 时跳转到其他页面并取消位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13817095/