1. 程式人生 > >ios 開發 推送消息的設置

ios 開發 推送消息的設置

adg 一個 iap ger uia oid style default play

///註銷推送

[[UIApplication sharedApplication] unregisterForRemoteNotifications];

///註冊推送

[[UIApplication sharedApplication] registerForRemoteNotifications];

///代碼控制關閉系統推送提示音

給用戶配置類設置一個sound健值 為nil就有聲音 反之沒聲音

- (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三種類型可以選擇設置

}

ios 開發 推送消息的設置