diff --git a/src/global.d.ts b/src/global.d.ts index ed3f548..a575991 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -12,4 +12,6 @@ interface Window { }; MiniKit?: import("./minikit").MiniKit; + + WorldApp?: any; } diff --git a/src/minikit.ts b/src/minikit.ts index 16196e6..6f3f050 100644 --- a/src/minikit.ts +++ b/src/minikit.ts @@ -34,6 +34,13 @@ export class MiniKit { [ResponseEvent.MiniAppWalletAuth]: () => {}, }; + private static sendInit() { + sendWebviewEvent({ + command: "init", + payload: { "minikit-version": 1 }, + }); + } + public static subscribe( event: E, handler: EventHandler @@ -58,6 +65,8 @@ export class MiniKit { if (typeof window !== "undefined" && !Boolean(window.MiniKit)) { try { window.MiniKit = MiniKit; + this.sendInit(); + console.log(window.WorldApp); } catch (error) { console.error("Failed to install MiniKit", error); return { success: false, error }; @@ -69,6 +78,11 @@ export class MiniKit { public static isInstalled(debug?: boolean) { if (debug) console.log("MiniKit is alive!"); + + if (typeof window !== "undefined" && !Boolean(window.WorldApp)) { + return false; + } + return true; }