顾海波

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

export class PushPlatform {
platformName: string;
regId: string;
constructor(platformName: string, regId: string) {
this.platformName = platformName;
this.regId = regId;
}
}
... ...
... ... @@ -22,6 +22,8 @@ import { UIAbility, AbilityConstant, Want } from '@kit.AbilityKit';
import { MethodChannel } from '@ohos/flutter_ohos';
import { notificationManager } from '@kit.NotificationKit';
import { common } from '@kit.AbilityKit';
import { PushPlatform } from './PushPlatform';
const TAG: string = "PushPluginMethodChannelHandler";
export default class PushPluginMethodChannelHandler implements MethodCallHandler {
... ... @@ -86,11 +88,9 @@ export default class PushPluginMethodChannelHandler implements MethodCallHandler
try {
const pushToken: string = await pushService.getToken();
const map:Map<string,string> =new Map<string,string>()
const params:Map<string,string> =new Map<string,string>()
params.set("platformName","huawei_ohos")
params.set("regId",pushToken)
const pushPlatform = new PushPlatform("huawei_ohos",pushToken)
map.set("type","ReceiveRegisterResult")
map.set("params", JSON.stringify(params))
map.set("params", JSON.stringify(pushPlatform))
this.methodChannel?.invokeMethod("onListener",map)
result.success(true)
} catch (err) {
... ...