From 27378f6ca07bdde818ef6f2942e9d11f64287012 Mon Sep 17 00:00:00 2001 From: zhangqinghe Date: Mon, 30 Mar 2015 10:28:01 +0800 Subject: [PATCH] add new iterface 'isPushStopped' and 'resumePush' for platform iOS --- plugin.xml | 3 +-- src/ios/Plugins/JPushPlugin.m | 41 ++++++++++++++++++++++++++++++++++- www/JPushPlugin.js | 7 +++--- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/plugin.xml b/plugin.xml index 519c14d..3f89360 100644 --- a/plugin.xml +++ b/plugin.xml @@ -35,12 +35,11 @@ + - - diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index a809d20..680c140 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -45,7 +45,46 @@ callbackSelector:@selector(tagsWithAliasCallback:tags:alias:) object:self]; } - + +-(void)resumePush:(CDVInvokedUrlCommand*)command{ + +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1 + if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { + //可以添加自定义categories + [APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge | + UIUserNotificationTypeSound | + UIUserNotificationTypeAlert) + categories:nil]; + } else { + //categories 必须为nil + [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | + UIRemoteNotificationTypeSound | + UIRemoteNotificationTypeAlert) + categories:nil]; + } +#else + //categories 必须为nil + [APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | + UIRemoteNotificationTypeSound | + UIRemoteNotificationTypeAlert) + categories:nil]; +#endif + +} +-(void)isPushStopped:(CDVInvokedUrlCommand*)command{ + + NSNumber *result; + if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications ]) { + result=@(1); + }else{ + result=@(0); + } + CDVPluginResult * pushResult=[self pluginResultForValue:result]; + if (pushResult) { + [self succeedWithPluginResult:pushResult withCallbackID:command.callbackId]; + } else { + [self failWithCallbackID:command.callbackId]; +}} -(void)setTags:(CDVInvokedUrlCommand *)command{ diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index ef539aa..d84f274 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -199,10 +199,9 @@ JPushPlugin.prototype.stopPush = function(){ } JPushPlugin.prototype.resumePush = function(){ - if(device.platform == "Android") { data=[] this.call_native("resumePush",data,null); - } + } JPushPlugin.prototype.setDebugMode = function(mode){ if(device.platform == "Android") { @@ -224,10 +223,10 @@ JPushPlugin.prototype.setLatestNotificationNum = function(num){ } JPushPlugin.prototype.isPushStopped = function(callback){ - if(device.platform == "Android") { + data=[]; this.call_native("isPushStopped",data,callback) - } + } JPushPlugin.prototype.init = function(){