推送保存消息

远程推送,在前台和后台时进入时 方法为  -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{

在完全退出时走得方法为  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  //推送
    
    if (launchOptions) {
        NSDictionary *userInfo = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
        NSInteger type = [userInfo[@"type"] integerValue];
        NSString *notiContent = userInfo[@"aps"][@"alert"];
        NotifiCationDao *dao = [NotifiCationDao new];
        [dao addNotiWithContent:notiContent type:type];
        [[NSNotificationCenter defaultCenter]postNotificationName:kDidReceiveRemoteNotificationKey object:userInfo];
        
    }

原文地址:https://www.cnblogs.com/huoxingdeguoguo/p/4818738.html