iOS:通过通知按下检测应用启动

时间:2015-03-15 09:59:01

标签: ios

有没有办法检测我的应用程序是否从主屏幕上显示的通知启动?

当我的应用程序进入后台时,我会安排UILocalNotification。当用户在主屏幕上按下此通知时,应用程序将再次启动。我希望通过按下通知获取我的应用程序再次启动的此信息。

我已经尝试了Send notification to user from app via notification API中提到的内容,但该应用不会调用该方法:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo

感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

您正在实施的委托方法是用于远程通知。要获取应用安排的本地通知的用户信息,您必须实施:

- (void)application:(UIApplication *)application
didReceiveLocalNotification:(UILocalNotification *)notification

Apple Documentation包含本地通知所需的所有信息。

答案 1 :(得分:0)

将这些行添加到您的app delegate中的didFinishLaunchingWithOptions函数

       NSDictionary *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (localNotif)
{
//your code here

}
相关问题