【iOS开发】判断app启动的方式(launchOptions)

(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// Override point for customization after application launch.

//用户自己点击启动

if(!launchOptions)

{

NSLog(@"用户点击app启动");

}

else

{

NSURL *url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];

//app 通过urlscheme启动

if (url) {

NSLog(@"app 通过urlscheme启动 url = %@",url);

}

UILocalNotification *localNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

//通过本地通知启动

if(localNotification)

{

NSLog(@"app 通过本地通知启动 localNotification = %@",localNotification);

}

NSDictionary *remoteCotificationDic = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];

//远程通知启动

if(remoteCotificationDic)

{

NSLog(@"app 通过远程推送通知启动 remoteCotificationDic = %@",remoteCotificationDic);

}

}

return YES;

}

你可能感兴趣的:(【iOS开发】判断app启动的方式(launchOptions))