feat: 新增iOS token截取,并回调到flutter业务层
This commit is contained in:
parent
aa93729f48
commit
9ca61b40d8
@ -197,12 +197,12 @@ public class JPushHelper {
|
||||
Log.d(TAG, "the channel is null");
|
||||
return;
|
||||
}
|
||||
Map<String, Object> 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<String, Object> 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) {
|
||||
|
||||
@ -620,9 +620,27 @@ static NSMutableArray<FlutterResult>* 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],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user