diff --git a/assets/Script/Manager.ts b/assets/Script/Manager.ts index 837bcfe..7a6093e 100644 --- a/assets/Script/Manager.ts +++ b/assets/Script/Manager.ts @@ -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}`); } /** 跨版本溝通 diff --git a/assets/Script/NativeClass.ts b/assets/Script/NativeClass.ts index 3d2b8c7..fc7af63 100644 --- a/assets/Script/NativeClass.ts +++ b/assets/Script/NativeClass.ts @@ -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: {