答案 0 :(得分:0)
您必须使用AppDelegate
方法(通常为application(_:didReceiveRemoteNotification:fetchCompletionHandler:)
)处理通知,然后以可在应用的任何屏幕中显示的形式启动视图。
您可以阅读UIApplicationDelegate
here的文档,回应通知和事件部分。
答案 1 :(得分:0)
您将从此处接收AppDelegate应用程序中的推送通知(_:确实接收远程通知:获取完成处理程序:):
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))handler
{
// 1. You can call your universal view from here
OR
// 2. You can post this local notification with information
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:myObject forKey:@"info"];
[[NSNotificationCenter defaultCenter] postNotificationName:@"showNotification"
object:nil
userInfo:userInfo];
}
对于第二选项,您需要添加观察者和接收方法:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(receiveNotification:)
name:@"showNotification"
object:nil];
-(void)receiveNotification:(NSNotification *)notification {
// call your view
}