检测是否该应用程序推出/从推送通知开 [英] Detect if the app was launched/opened from a push notification
本文介绍了检测是否该应用程序推出/从推送通知开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能知道,从一个推送通知,如果应用程序发起/开?
Is it possible to know if the app was launched/opened from a push notification?
我猜启动事件都可以在这里抓到:
I guess the launching event can be caught here:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (launchOptions != nil) {
// Launched from push notification
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
}
}
但是,我怎么能检测到它是从一个推送通知,当打开该应用程序是在后台?
However, how can I detect it was opened from a push notification when the app was on background?
推荐答案
请参阅此code:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
if ( application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground )
{
//opened from a push notification when the app was on background
}
}
同
-(void)application:(UIApplication *)application didReceiveLocalNotification (UILocalNotification *)notification
这篇关于检测是否该应用程序推出/从推送通知开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文