天天看点

各种情况下收到push通知时的函数调用情况

一.程序在前台

调用didReceiveRemoteNotification(此时applicationState为UIApplicationStateActive)

二.程序在后台

1.点击push通知:调用didReceiveRemoteNotification(此时applicationState为UIApplicationStateInactive)

2.点击应用程序图标:啥也不调(the application will enter foreground)

三.程序未运行

1.点击push通知:调用didFinishLaunchingWithOptions(launchOptions的UIApplicationLaunchOptionsRemoteNotificationKey跟didReceiveRemoteNotification的userInfo是一样样的)

2.点击应用程序图标:调用didFinishLaunchingWithOptions(launchOptions为nil)