从我的应用程序中,即使应用程序处于非活动状态或终止,它也可以收到通知。但是,当我点击通知打开它时,它将打开主页而不是我希望的“期刊页面”。
这仅在应用程序处于活动状态或处于后台时才有效。谁能告诉我一些关于这个问题的事情?我尝试将所有三个(活动、非活动、背景)的 UIApplicationState 放在 didReceiveRemoteNotification 方法中,但是即使我在应用程序处于活动状态或在后台打开通知,每个通知也会进入后台状态。
谁能给我任何想法来解决这个问题?
这是远程通知的方法:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if([userInfo valueForKey:@"app"]) {
NSString *action_app = [userInfo valueForKey:@"app"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:action_app forKey:@"app"];
NSLog(@"detect app value from UA ====> %@",action_app);
SampleViewController *sample=[[SampleViewController alloc]init];
[sample viewDidAppear:YES];
}else if([userInfo valueForKey:@"url"]){
NSString *action_url = [userInfo valueForKey:@"url"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:action_url forKey:@"url"];
NSLog(@"detect url value from UA ====> %@",action_url);
SampleViewController *sample=[[SampleViewController alloc]init];
[sample viewDidAppear:YES];
}else{
NSLog(@"---nothing to read---");
}
// Send the alert to UA so that it can be handled and tracked as a direct response. This call
// is required.
[[UAPush shared] handleNotification:userInfo applicationState:application.applicationState];
// Reset the badge after a push received (optional)
[[UAPush shared] resetBadge];
// Open inboxData when receive notification
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.blankviewController = [[SampleViewController alloc] initWithNibName:@"SampleViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.blankviewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
}