ios 开发 推送消息的设置

///注销推送

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 20.0px Menlo; color: #587ea8 }
span.s1 { color: #000000 }
span.s2 { color: #c35900 }
span.s3 { }

[[UIApplication sharedApplication] unregisterForRemoteNotifications];

 

///注册推送

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 20.0px Menlo; color: #587ea8 }
span.s1 { color: #000000 }
span.s2 { color: #c35900 }
span.s3 { }

[[UIApplication sharedApplication] registerForRemoteNotifications];

 

///代码控制关闭系统推送提示音

给用户配置类设置一个sound健值 为nil就有声音 反之没声音

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 20.0px Menlo; color: #000000 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 20.0px Menlo; color: #cf8724 }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 20.0px Menlo; color: #587ea8 }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 20.0px Menlo; color: #c35900 }
span.s1 { }
span.s2 { color: #36568a }
span.s3 { color: #c35900 }
span.s4 { color: #000000 }
span.s5 { color: #587ea8 }
span.s6 { color: #e82300 }
span.s7 { font: 20.0px “PingFang SC” }

– (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{

    // Required

    NSDictionary * userInfo = notification.request.content.userInfo;

    if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {

        [JPUSHService handleRemoteNotification:userInfo];

    }

    NSUserDefaults * userDefault = [NSUserDefaults standardUserDefaults];

    if ([userDefault objectForKey:@”sound”]) {

        AudioServicesPlaySystemSound(00);

    }else{

        AudioServicesPlaySystemSound(1312);

    }

    completionHandler(UNNotificationPresentationOptionAlert); // 需要执行这个方法,选择是否提醒用户,有BadgeSoundAlert三种类型可以选择设置

}