func application(application: UIApplication,didReceiveRemoteNotification data: [NSObject : AnyObject]) { var dat = JSON(data) if application.applicationState == UIApplicationState.Active { // app was already in the foreground println("App is in foreground") processNotification(dat) }else{ // app was just brought from background to foreground via PUSH println("App brought back via PUSH") processNotification(dat) } }
这是我检查推送通知的方式.但是,如果我发送推送通知,用户会错过它,然后通过图标打开应用程序?如何从图标中查看应用程序的打开时间?
解决方法
The
UIApplicationDelegate
protocol定义了几种方法,可以将代码添加到应用程序的几个生命周期事件中.
您特别感兴趣的是:
> application(_:willFinishLaunchingWithOptions