From f67e566f2a41c0dc0bdcaf8cee9cbfb859ad0455 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Fri, 26 Aug 2022 16:36:46 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E5=8F=96=E5=BE=97FCMToken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Script/Manager.ts | 3 +++ assets/Script/NativeClass.ts | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) 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: {