diff --git a/android/src/main/java/com/jiguang/jpush/JPushHelper.java b/android/src/main/java/com/jiguang/jpush/JPushHelper.java index e888095..17a4ac9 100644 --- a/android/src/main/java/com/jiguang/jpush/JPushHelper.java +++ b/android/src/main/java/com/jiguang/jpush/JPushHelper.java @@ -197,12 +197,12 @@ public class JPushHelper { Log.d(TAG, "the channel is null"); return; } - Map notification = new HashMap<>(); - notification.put("cmd", cmdMessage.cmd); - notification.put("errorCode", cmdMessage.errorCode); - notification.put("msg", cmdMessage.msg); - notification.put("extras", bundleToMap(cmdMessage.extra)); - channel.invokeMethod("onCommandResult", notification); +// Map notification = new HashMap<>(); +// notification.put("cmd", cmdMessage.cmd); +// notification.put("errorCode", cmdMessage.errorCode); +// notification.put("msg", cmdMessage.msg); +// notification.put("extras", bundleToMap(cmdMessage.extra)); + channel.invokeMethod("onCommandResult", bundleToMap(cmdMessage.extra)); } public void onNotifyMessageUnShow(NotificationMessage notificationMessage) { diff --git a/ios/Classes/JPushPlugin.m b/ios/Classes/JPushPlugin.m index 6e4ed8f..e6bca21 100644 --- a/ios/Classes/JPushPlugin.m +++ b/ios/Classes/JPushPlugin.m @@ -620,9 +620,27 @@ static NSMutableArray* getRidResults; } - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { + NSDictionary *tokenInfo = @{ + @"code" : @0, + @"cmd" : @100, + @"token" : [self hexStringFromData:deviceToken], + @"platform" : @7, + }; + [_channel invokeMethod:@"onCommandResult" arguments:tokenInfo]; [JPUSHService registerDeviceToken:deviceToken]; } +- (NSString *)hexStringFromData:(NSData *)data { + const unsigned char *dataBuffer = (const unsigned char *)[data bytes]; + NSMutableString *hexString = [NSMutableString stringWithCapacity:data.length * 2]; + + for (NSInteger i = 0; i < data.length; i++) { + [hexString appendFormat:@"%02x", dataBuffer[i]]; + } + + return [hexString copy]; +} + - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings { NSDictionary *settingsDictionary = @{ @"sound" : [NSNumber numberWithBool:notificationSettings.types & UIUserNotificationTypeSound],