diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index 2c4e454..7417e32 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -1,12 +1,3 @@ - -// -// PushTalkPlugin.m -// PushTalk -// -// Created by zhangqinghe on 13-12-13. -// -// - #import "JPushPlugin.h" #import "JPUSHService.h" #import @@ -247,11 +238,76 @@ [dic setValue:[NSNumber numberWithUnsignedInteger:iResCode] forKey:@"errorCode"]; result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dic]; } + + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; } seq:[sequence integerValue]]; } -(void)setAlias:(CDVInvokedUrlCommand*)command { + NSDictionary* params = [command.arguments objectAtIndex:0]; + NSNumber* sequence = params[@"sequence"]; + NSString* alias = params[@"alias"]; + [JPUSHService setAlias:alias completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) { + NSMutableDictionary* dic = [[NSMutableDictionary alloc] init]; + [dic setObject:sequence forKey:@"sequence"]; + + CDVPluginResult* result; + + if (iResCode == 0) { + [dic setObject:iAlias forKey:@"alias"]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic]; + + } else { + [dic setValue:[NSNumber numberWithUnsignedInteger:iResCode] forKey:@"errorCode"]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dic]; + } + + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; + } seq:[sequence integerValue]]; +} + +-(void)deleteAlias:(CDVInvokedUrlCommand*)command { + NSDictionary* params = [command.arguments objectAtIndex:0]; + NSNumber* sequence = params[@"sequence"]; + + [JPUSHService deleteAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) { + NSMutableDictionary* dic = [[NSMutableDictionary alloc] init]; + [dic setObject:sequence forKey:@"sequence"]; + + CDVPluginResult* result; + + if (iResCode == 0) { + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic]; + } else { + [dic setValue:[NSNumber numberWithUnsignedInteger:iResCode] forKey:@"errorCode"]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dic]; + } + + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; + } seq:[sequence integerValue]]; +} + +-(void)getAlias:(CDVInvokedUrlCommand*)command { + NSDictionary* params = [command.arguments objectAtIndex:0]; + NSNumber* sequence = params[@"sequence"]; + + [JPUSHService getAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) { + NSMutableDictionary* dic = [[NSMutableDictionary alloc] init]; + [dic setObject:sequence forKey:@"sequence"]; + + CDVPluginResult* result; + + if (iResCode == 0) { + [dic setObject:iAlias forKey:@"alias"]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic]; + } else { + [dic setValue:[NSNumber numberWithUnsignedInteger:iResCode] forKey:@"errorCode"]; + result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dic]; + } + + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; + } seq:[sequence integerValue]]; } -(void)getRegistrationID:(CDVInvokedUrlCommand*)command{ @@ -457,16 +513,7 @@ [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; } -#pragma mark 设置标签及别名回调 --(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias { - if (resultCode == 0) { // Success - - } else { - - } -} - -- (void)networkDidReceiveMessage:(NSNotification *)notification { +-(void)networkDidReceiveMessage:(NSNotification *)notification { if (notification && notification.userInfo) { [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveMessage jsString:[notification.userInfo toJsonString]]; diff --git a/www/JPushPlugin.js b/www/JPushPlugin.js index f388b8e..f31fbba 100644 --- a/www/JPushPlugin.js +++ b/www/JPushPlugin.js @@ -153,7 +153,7 @@ JPushPlugin.prototype.setAlias = function (params, successCallback, errorCallbac /** * 删除别名。 * - * @param params = { 'sequence': number, 'alias': string } + * @param params = { 'sequence': number } */ JPushPlugin.prototype.deleteAlias = function (params, successCallback, errorCallback) { this.callNative('deleteAlias', [params], successCallback, errorCallback)