Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodePush causes uncaught exceptions when previewing project on a web browser #40

Open
Clovel opened this issue Jul 16, 2021 · 3 comments

Comments

@Clovel
Copy link

Clovel commented Jul 16, 2021

Description

When debugging or developing an app using a web browser (for example for styling development), CodePush throws an uncaught exception that does not come from the app's source code.

Additional Information

This issue does not happen with other Capacitor plugins that are "mobile-only". A good example is the Firebase notification plugin.

Screenshots

Exception :

Capture_d_écran_2021-06-30_à_15 39 29

Code extract :
Capture_d_écran_2021-06-30_à_15 40 08

@ashish141199
Copy link

You are not supposed to use it on web.
Use an if statement:

something like this

if(platform == 'web') return;
// rest of the code

@Clovel
Copy link
Author

Clovel commented Jul 24, 2021

I know that. But simply importing the plugin, registering it, causes the exception. On the contrary, other Capacitor or Cordova plugins catch these exceptions.

We should mimic that behavior for this plugin.

@Clovel
Copy link
Author

Clovel commented Sep 20, 2021

Perhaps doing something like this would be acceptable ?

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;

The downside is that the nullish case should be managed by the developer usign this package.

Clovel added a commit to loginline/capacitor-codepush that referenced this issue Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants