顾海波

【修复】鸿蒙regId不能正常获取

  1 +
  2 +export class PushPlatform {
  3 +
  4 + platformName: string;
  5 + regId: string;
  6 + constructor(platformName: string, regId: string) {
  7 + this.platformName = platformName;
  8 + this.regId = regId;
  9 + }
  10 +}
@@ -22,6 +22,8 @@ import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit'; @@ -22,6 +22,8 @@ import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit';
22 import { MethodChannel } from '@ohos/flutter_ohos'; 22 import { MethodChannel } from '@ohos/flutter_ohos';
23 import { notificationManager } from '@kit.NotificationKit'; 23 import { notificationManager } from '@kit.NotificationKit';
24 import { common } from '@kit.AbilityKit'; 24 import { common } from '@kit.AbilityKit';
  25 +import { PushPlatform } from './PushPlatform';
  26 +
25 const TAG: string = "PushPluginMethodChannelHandler"; 27 const TAG: string = "PushPluginMethodChannelHandler";
26 28
27 export default class PushPluginMethodChannelHandler implements MethodCallHandler { 29 export default class PushPluginMethodChannelHandler implements MethodCallHandler {
@@ -86,11 +88,9 @@ export default class PushPluginMethodChannelHandler implements MethodCallHandler @@ -86,11 +88,9 @@ export default class PushPluginMethodChannelHandler implements MethodCallHandler
86 try { 88 try {
87 const pushToken: string = await pushService.getToken(); 89 const pushToken: string = await pushService.getToken();
88 const map:Map<string,string> =new Map<string,string>() 90 const map:Map<string,string> =new Map<string,string>()
89 - const params:Map<string,string> =new Map<string,string>()  
90 - params.set("platformName","huawei_ohos")  
91 - params.set("regId",pushToken) 91 + const pushPlatform = new PushPlatform("huawei_ohos",pushToken)
92 map.set("type","ReceiveRegisterResult") 92 map.set("type","ReceiveRegisterResult")
93 - map.set("params", JSON.stringify(params)) 93 + map.set("params", JSON.stringify(pushPlatform))
94 this.methodChannel?.invokeMethod("onListener",map) 94 this.methodChannel?.invokeMethod("onListener",map)
95 result.success(true) 95 result.success(true)
96 } catch (err) { 96 } catch (err) {