[add] 取得FCMToken

This commit is contained in:
建喵 2022-08-26 16:36:46 +08:00
parent c74d8648fd
commit f67e566f2a
2 changed files with 28 additions and 1 deletions

View File

@ -66,6 +66,9 @@ export default class Manager extends cc.Component {
cc.view.setResizeCallback(this._resize.bind(this));
this._resize();
const FCMToken: string = NativeClass.Instance.GetFCMToken();
console.log(`FCMToken ${FCMToken}`);
}
/**

View File

@ -132,6 +132,30 @@ export default class NativeClass extends cc.Component {
//#region Custom Function
/** GetFCMToken */
public GetFCMToken(): string {
let resp: any = "";
switch (cc.sys.os) {
case cc.sys.OS_WINDOWS: {
// 網頁端
break;
}
case cc.sys.OS_ANDROID: {
break;
}
case cc.sys.OS_IOS: {
resp = jsb.reflection.callStaticMethod("AppController", "GetFCMToken");
break;
}
default: {
break;
}
}
return resp;
}
/**
* TTS_Play
* @param {string} msg msg
@ -139,7 +163,7 @@ export default class NativeClass extends cc.Component {
public TTS_Play(msg: string): void {
switch (cc.sys.os) {
case cc.sys.OS_WINDOWS: {
// // 網頁端
// 網頁端
break;
}
case cc.sys.OS_ANDROID: {