1,推送已至,点通知栏;
a)若App在UIApplicationStateActive(活动)状态,调用
//接收到推送消息
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
//处理推送消息,可以把处理推送的方法放在下面方法里面
[self handleRemoteInformation:userInfo]; }
b) 若App不在活动状态,调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions ,在其中可以判断
//判断程序是不是由点击通知栏消息启动的 if (launchOptions){ //截取apns推送的消息 NSDictionary *pushInfo = [launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"]; //处理推送消息 [self handleRemoteInformation:pushInfo]; }
2,推送至,直接点击Icon,收不到任何消息;