launchOptions中的可能键值见UIApplication Class Reference的Launch Options Keys节 。
代码区分不同的启动,如点击推送可以做出跳转
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSURL *url = [options objectForKey:UIApplicationLaunchOptionsURLKey]; if(url) { //由其他应用程序通过openURL:启动 } NSString *bundleId = [options objectForKey:UIApplicationLaunchOptionsSourceApplicationKey]; if(bundleId) { //对应启动的源应用程序的bundle ID (NSString) } UILocalNotification * localNotify = [options objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if(localNotify) { //点击本地推送进来后 } NSDictionary * userInfo = [options objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; if(userInfo) { //点击推送进来后 } }