本文介绍了iOS / XCode:如何知道该应用程序已经启动与点击通知或在跳板应用程序图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有一种方法可以知道是否已经启动了一个应用程序(可以关闭或在后台打开):
- 通知中心(在通知中心)?
- 或跳板上的应用程式图示?
感谢!!
解决方案
输入代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification * notification = launchOptions [UIApplicationLaunchOptionsLocalNotificationKey] ;
if(notification){
//从通知启动
} else {
//从跳板
}
}
在。 p>
I would like to know if there is a way to know if an app (which can be closed or open in background) has been launched with a click on:
- a notification (in the notification center) ?
- or the app icon on the springboard ?
Thanks !!
解决方案
put this code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *notification = launchOptions[UIApplicationLaunchOptionsLocalNotificationKey];
if (notification) {
// launched from notification
} else {
// from the springboard
}
}
in your UIApplicationDelegate
.
这篇关于iOS / XCode:如何知道该应用程序已经启动与点击通知或在跳板应用程序图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!