Check for launching from UILocalNotification in Swift

倾然丶 夕夏残阳落幕 提交于 2019-12-03 03:31:32

If your App is running in background, the "application didFinishLaunching" method will not be called. It has already been launched.

In this case you should do your job in the "application didReceiveLocalNotification" method.

func application(application: UIApplication!, didReceiveLocalNotification notification: UILocalNotification!) {
        // do your jobs here
}

LaunchOptions will be nil if you launch the application directly. The code will be running if you launch the application through the notifications rather than launch the application directly.

If you launch the application directly, then you need some other ways to solve this. Like use the time of the LocalNotification and the current time, and decide which view to show.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!