iOS添加手机号设置接口

This commit is contained in:
JoshLi 2021-07-28 10:58:19 +08:00
parent fad4745e01
commit bc9e441fe2
2 changed files with 26 additions and 0 deletions

View File

@ -73,6 +73,9 @@ static NSMutableDictionary *_jpushEventCache;
-(void)addDismissActions:(CDVInvokedUrlCommand*)command;
-(void)addNotificationActions:(CDVInvokedUrlCommand*)command;
// 设置手机号
-(void)setMobileNumber:(CDVInvokedUrlCommand*)command;
/*
* js中可监听到的事件
* jpush.openNotification app

View File

@ -510,6 +510,29 @@
[[UNUserNotificationCenter currentNotificationCenter] setNotificationCategories:[NSSet setWithObject:category]];
}
#pragma mark -
-(void)setMobileNumber:(CDVInvokedUrlCommand *)command {
NSDictionary* params = [command.arguments objectAtIndex:0];
NSNumber* sequence = params[@"sequence"];
NSString* number = params[@"mobileNumber"];
[JPUSHService setMobileNumber:number completion:^(NSError *error) {
NSMutableDictionary* dic = [[NSMutableDictionary alloc] init];
[dic setObject:sequence forKey:@"sequence"];
CDVPluginResult* result;
if (error) {
[dic setValue:[NSNumber numberWithUnsignedInteger:error.code] forKey:@"code"];
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:dic];
}
else {
// success
[dic setObject:number forKey:@"mobileNumber"];
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic];
}
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
}];
}
#pragma mark -
+(void)setupJPushSDK:(NSDictionary*)userInfo{