当用户关闭时,我需要检测用户何时从推送弹出视图打开我的应用程序。
我试试这个:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (launchOptions != nil) {
// Launched from push notification
NSDictionary *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
}
}
但总是launchOptions
返回nil。
答案 0 :(得分:0)
如果喜欢这个:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
{
if (application.applicationState == UIApplicationStateActive)
{
NSLog(@"push Application State Active");
}
else if(application.applicationState == UIApplicationStateInactive || application.applicationState == UIApplicationStateBackground)
{
}
}