关于点击推送消息打开app

官方链接:
https://developer.apple.com/documentation/uikit/uiapplicationdelegate#//apple_ref/occ/intfm/UIApplicationDelegate/application:didFinishLaunchingWithOptions:

// iOS 程序启动时总会调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    self.window.rootViewController = [GFBTempRootVC new];
    
    //////// 可以把内容alert出来查看(这里我用了工程中封装好的,大家用系统的alert即可)////////////////
    CustomPopUpView *view = [[CustomPopUpView alloc]initWithFrame:AppWindow.frame WithPopUpViewType:PopUpViewPrompt WithTitle:@"launchOptions" WithPromptTitle:[launchOptions mj_JSONString] WithImage:nil];
    [AppWindow addSubview:view];
    return YES;
}

其中参数launchOptions为NSDictionary类型的对象,里面存储有此程序启动的原因。

  • 若用户直接启动,lauchOptions内无数据;
  • 若由其他应用程序通过openURL:启动,则UIApplicationLaunchOptionsURLKey对应的对象为启动URL(NSURL),UIApplicationLaunchOptionsSourceApplicationKey对应启动的源应用程序的bundle ID (NSString);
  • 若由本地通知启动,则UIApplicationLaunchOptionsLocalNotificationKey对应的是为启动应用程序的的本地通知对象(UILocalNotification);
  • 若由远程通知启动,则UIApplicationLaunchOptionsRemoteNotificationKey对应的是启动应用程序的的远程通知信息userInfo(NSDictionary);
  • 其他key还有UIApplicationLaunchOptionsAnnotationKey,UIApplicationLaunchOptionsLocationKey,
    UIApplicationLaunchOptionsNewsstandDownloadsKey。

你可能感兴趣的:(关于点击推送消息打开app)