ios如何在推送通知中启动应用程序
当用户在ios中收到推送通知时,我在启动特定的应用程序页面时面临问题 这可能吗ios如何在推送通知中启动应用程序,ios,swift,push-notification,apple-push-notifications,Ios,Swift,Push Notification,Apple Push Notifications,当用户在ios中收到推送通知时,我在启动特定的应用程序页面时面临问题 这可能吗 如果是,请在这方面帮助我。您可以在收到任何远程通知时向自己发送通知,并且通过将UIViewController注册到此通知,您可以在收到通知后打开特定的UIViewController - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{ [[NSNotif
如果是,请在这方面帮助我。您可以在收到任何远程通知时向自己发送通知,并且通过将
UIViewController
注册到此通知,您可以在收到通知后打开特定的UIViewController
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo];
}
在FirstViewController.m中注册以侦听此通知
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil];
}
在方法内部,您可以打开特定的viewController
-(void)pushNotificationReceived{
[self presentViewController:self.secondViewController animated:YES completion:nil];
}
最后,在dealloc方法中从通知中取消注册当前viewController
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
如果您在这方面遇到任何问题,请告诉我。您可以在收到任何远程通知时向自己发送通知,通过将
UIViewController
注册到此通知,您可以在收到通知后打开特定的UIViewController
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotification" object:nil userInfo:userInfo];
}
在FirstViewController.m中注册以侦听此通知
-(void)viewDidLoad{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pushNotificationReceived) name:@"pushNotification" object:nil];
}
在方法内部,您可以打开特定的viewController
-(void)pushNotificationReceived{
[self presentViewController:self.secondViewController animated:YES completion:nil];
}
最后,在dealloc方法中从通知中取消注册当前viewController
-(void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
如果您在这方面遇到任何问题,请告诉我。启动应用程序页面时可能会出现重复,您的意思是打开应用程序吗?详细说明…启动应用程序页面时可能会出现重复,您的意思是打开应用程序?详细说明……检查。谢谢你的快速帮助。正在检查。谢谢你的快速帮助。