diff --git a/assets/Script/Manager.ts b/assets/Script/Manager.ts index ab93178..90f278d 100644 --- a/assets/Script/Manager.ts +++ b/assets/Script/Manager.ts @@ -1,3 +1,4 @@ +import { CoroutineV2 } from "./Engine/CatanEngine/CoroutineV2/CoroutineV2"; import { System_Eevent } from "./Engine/CatanEngine/CSharp/System/System_Eevent"; import NativeClass from "./NativeClass"; @@ -109,7 +110,16 @@ export default class Manager extends cc.Component { } public onLoadOK(): void { + CoroutineV2.Single(this.GetFCMToken()).Start(); + } + + public *GetFCMToken(): IterableIterator { const FCMToken: string = NativeClass.Instance.GetFCMToken(); + if (!FCMToken) { + yield CoroutineV2.WaitTime(1); + yield this.GetFCMToken(); + return; + } console.log(`FCMToken ${FCMToken}`); NativeClass.Instance.CocosBridge(System_Eevent.SetFCMToken, `"${FCMToken}"`); }