我怎样才能检测到第一次发布
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// if very first launch than perform actionA
// else perform actionB
}
Run Code Online (Sandbox Code Playgroud)
方法?
我收到远程通知,并根据通知类型更改导航控制器的视图控制器.
当应用程序在前台,或者应用程序在后台但未完全关闭时(从多任务栏),一切正常.
但是,当应用程序关闭并收到远程通知时,它会在打开时立即崩溃.我在设置ViewControllers的方式上做错了吗?
这是一些代码.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions {
// Push required screens into navigation controller
UILocalNotification *remoteNotif = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
//Accept push notification when app is not open
if (remoteNotif) {
[self handleRemoteNotification:application userInfo:remoteNotif.userInfo];
return YES;
}
[window addSubview:navigationController.view];
[window makeKeyAndVisible];
return YES;
}
-(void) handleRemoteNotification:(UIApplication *)application userInfo:(NSDictionary *)userInfo {
application.applicationIconBadgeNumber = 0;
NSMutableArray *viewControllers = [NSMutableArray array];
[viewControllers addObject:driverWaitViewController];
[viewControllers addObject:newJobsViewController];
[navigationController setViewControllers:viewControllers];
}
Run Code Online (Sandbox Code Playgroud) iphone objective-c push-notification apple-push-notifications