diff --git a/README.md b/README.md index e421b81..5822eb5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # JPush PhoneGap / Cordova Plugin [![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin) -[![release](https://img.shields.io/badge/release-3.2.0-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases) +[![release](https://img.shields.io/badge/release-3.2.1-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases) [![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin) [![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1) diff --git a/doc/iOS_API.md b/doc/iOS_API.md index 2ed7f68..0f14a21 100644 --- a/doc/iOS_API.md +++ b/doc/iOS_API.md @@ -175,9 +175,9 @@ window.plugins.jPushPlugin.getRegistrationID(function(data) { #### 接口定义 ``` -JPushPlugin.prototype.setTagsWithAlias(tags, alias) -JPushPlugin.prototype.setTags(tags) -JPushPlugin.prototype.setAlias(alias) +JPushPlugin.prototype.setTagsWithAlias(tags, alias, successCallback, errorCallback) +JPushPlugin.prototype.setTags(tags, successCallback) +JPushPlugin.prototype.setAlias(alias, errorCallback) ``` #### 参数说明 @@ -197,21 +197,6 @@ JPushPlugin.prototype.setAlias(alias) - 有效的别名组成:字母(区分大小写)、数字、下划线、汉字。 - 限制:alias 命名长度限制为 40 字节(判断长度需采用 UTF-8 编码)。 -#### 返回值说明 - -函数本身无返回值,但需要注册 `jpush.setTagsWithAlias` 事件来监听设置结果。 - -```js -var onTagsWithAlias = function(event) { - console.log("onTagsWithAlias") - var result = "result code:"+event.resultCode + " " - result += "tags:" + event.tags + " " - result += "alias:" + event.alias + " " - $("#tagAliasResult").html(result) -} -document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false) -``` - #### 错误码定义 | Code | 描述 | 详细解释 | diff --git a/package.json b/package.json index 2378943..bef763d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jpush-phonegap-plugin", - "version": "3.2.0", + "version": "3.2.1", "description": "JPush for cordova plugin", "cordova": { "id": "jpush-phonegap-plugin", diff --git a/plugin.xml b/plugin.xml index c664b57..77788cc 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.2.1"> JPush JPush for cordova plugin diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index c07adf4..6ca27e2 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -99,44 +99,47 @@ -(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command{ NSString *alias = [command argumentAtIndex:0]; NSArray *tags = [command argumentAtIndex:1]; - - [JPUSHService setTags:[NSSet setWithArray:tags] - alias:alias - fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) { - CDVPluginResult *result; - if (iResCode == 0) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; - } else { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil]; - } + + [JPUSHService setTags:[NSSet setWithArray:tags] + alias:alias + fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) { + CDVPluginResult *result; + if (iResCode == 0) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil]; + } + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; }]; } -(void)setTags:(CDVInvokedUrlCommand*)command{ - NSArray *tags = command.arguments; - [JPUSHService setTags:[NSSet setWithArray:tags] - alias:nil - fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) { - CDVPluginResult *result; - if (iResCode == 0) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; - } else { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil]; - } + NSArray *tags = command.arguments; + [JPUSHService setTags:[NSSet setWithArray:tags] + alias:nil + fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) { + CDVPluginResult *result; + if (iResCode == 0) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil]; + } + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; }]; } -(void)setAlias:(CDVInvokedUrlCommand*)command{ NSString *alias = [command argumentAtIndex:0]; - [JPUSHService setTags:nil - alias:alias - fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) { - CDVPluginResult *result; - if (iResCode == 0) { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; - } else { - result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil]; - } + [JPUSHService setTags:nil + alias:alias + fetchCompletionHandle:^(int iResCode, NSSet *iTags, NSString *iAlias) { + CDVPluginResult *result; + if (iResCode == 0) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:nil]; + } else { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:nil]; + } + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; }]; } @@ -344,11 +347,11 @@ } #pragma mark 设置标签及别名回调 --(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias { - if (resultCode == 0) { // Success - - } else { - +-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias { + if (resultCode == 0) { // Success + + } else { + } }