From 0bb6838477b948421667467f4c5da5011f06ff4f Mon Sep 17 00:00:00 2001 From: "E.B" <57380422@qq.com> Date: Tue, 12 Jul 2016 11:16:58 +0800 Subject: [PATCH] iOS - update new API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.添加检测用户通知设置的 API --- src/ios/Plugins/JPushPlugin.h | 3 +++ src/ios/Plugins/JPushPlugin.m | 13 +++++++++++++ www/JPushPlugin.js | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/src/ios/Plugins/JPushPlugin.h b/src/ios/Plugins/JPushPlugin.h index 1164636..8ce48f4 100644 --- a/src/ios/Plugins/JPushPlugin.h +++ b/src/ios/Plugins/JPushPlugin.h @@ -58,6 +58,9 @@ //地理位置上报 [latitude,longitude] -(void)setLocation:(CDVInvokedUrlCommand*)command; +//检查用户的推送设置情况 +-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command; + /* * 以下为js中可监听到的事件 * jpush.openNotification 点击推送消息启动或唤醒app diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index f0098c3..9b65ffc 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -259,6 +259,19 @@ static NSDictionary *_launchOptions = nil; [JPUSHService setLatitude:[((NSString*)command.arguments[0]) doubleValue] longitude:[((NSString*)command.arguments[1]) doubleValue]]; } +-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command{ + if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { + UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings]; + NSString *description = [settings description]; + [self handleResultWithValue:description command:command]; + }else{ + UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; + NSNumber *number = [NSNumber numberWithInteger:type]; + [self handleResultWithValue:number command:command]; + } + +} + #pragma mark- 内部方法 +(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{ _launchOptions = theLaunchOptions; diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index 64d273c..b426200 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -210,6 +210,12 @@ JPushPlugin.prototype.getApplicationIconBadgeNumber = function(callback) { } } +JPushPlugin.prototype.getUserNotificationSettings = function(callback) { + if(this.isPlatformIOS()) { + this.call_native("getUserNotificationSettings", [], callback); + } +} + // Android methods JPushPlugin.prototype.setDebugMode = function(mode) { if(device.platform == "Android") {