iOS 推送通知处理

//这是程序杀死后再通过点击通知进入时调用的方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    if (launchOptions) {
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
        NSDictionary *userInfo = [launchOptions objectForKey: UIApplicationLaunchOptionsRemoteNotificationKey];
        [self handleRemoteNotificationWithUserInfo:userInfo];
    }

}

 

//App状态为正在前台或者后台运行,那么此函数将被调用

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
    if (application.applicationState != UIApplicationStateActive) {
       [self handleRemoteNotificationWithUserInfo:userInfo];
    }
}

 

// 接到通知以后的跳转方法

- (void)handleRemoteNotificationWithUserInfo:(NSDictionary *)userInfo {
     [self.window.rootViewController presentViewController:XXXVC animated:YES completion:nil];
}

posted @ 2016-08-03 16:06  小C酱  阅读(195)  评论(0编辑  收藏  举报