Skip to content

Commit

Permalink
[Fixes mpaghq#40] Managed web platform for codePush instance export
Browse files Browse the repository at this point in the history
Signed-off-by: Clovis Durand <[email protected]>
  • Loading branch information
Clovel committed Sep 20, 2021
1 parent 36e607c commit 89281e5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/codePush.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Capacitor } from "@capacitor/core";
import { ConfirmResult, Dialog } from "@capacitor/dialog";
import { AcquisitionStatus, NativeUpdateNotification } from "code-push/script/acquisition-sdk";
import { Callback, ErrorCallback, SuccessCallback } from "./callbackUtil";
import { CodePushUtil } from "./codePushUtil";
Expand All @@ -10,7 +12,6 @@ import { RemotePackage } from "./remotePackage";
import { Sdk } from "./sdk";
import { SyncOptions, UpdateDialogOptions } from "./syncOptions";
import { SyncStatus } from "./syncStatus";
import { ConfirmResult, Dialog } from "@capacitor/dialog";

interface CodePushCapacitorPlugin {

Expand Down Expand Up @@ -534,5 +535,13 @@ enum ReportStatus {
UPDATE_ROLLED_BACK = 2
}

export const codePush = new CodePush();
(window as any).codePush = codePush;
let codePushInstance: CodePush | null = null;
if(Capacitor.getPlatform() !== 'web') {
codePushInstance = new CodePush();
(window as any).codePush = codePushInstance;
} else {
/* Can't use CodePush without Capacitor */
/* The instance will be null */
}

export const codePush: CodePush | null = codePushInstance;

0 comments on commit 89281e5

Please sign in to comment.