Local and Remote Notifications Appear Different to Apps
If your app is frontmost when a local or remote notification arrives, the application:didReceiveRemoteNotification:
or application:didReceiveLocalNotification:
method is called on its app delegate. If your app is not frontmost or not running, you handle the notifications by checking the options dictionary passed to the application:didFinishLaunchingWithOptions:
of your app delegate for either the UIApplicationLaunchOptionsLocalNotificationKey
or UIApplicationLaunchOptionsRemoteNotificationKey
key. For more details about handling notifications, see Scheduling, Registering, and Handling Notifications.
当收到本地或远程通知时,若应用处于前台(frontmost:不知道是这意思不:( ),则应用代码会调用application:didReceiveRemoteNotification:或application:didReceiveLocalNotification:方法(验证时是当点击推送消息,应用从background进入foreground时会调用);若应用处于not frontmost或是没运行状态,你需要通过应用代理中的application:didFinishLaunchingWithOptions:方法里可选的字典项UIApplicationLaunchOptionsLocalNotificationKey或UIApplicationLaunchOptionsRemoteNotificationKey来处理通知,具体处理通知的细节详见Scheduling, Registering, and Handling Notifications。