Giter VIP home page Giter VIP logo

Comments (7)

lincolnthree avatar lincolnthree commented on August 15, 2024

Actually this seems to be quite common:

image

from capacitor-codepush.

lincolnthree avatar lincolnthree commented on August 15, 2024

This appears to be an issue when the CodePush TS/JS library is not loaded at the time when the native plugin attempts to register the onDeviceReady listener. The injected/eval JS hooks in the native CodePush manager code for Android/iOS should probably be refactored to handle this situation.

Since Capacitor does not guarantee the client JS code is loaded until the application imports the CodePush libraries (unlike Cordova which loads all plugin code up front), we will need to provide deferred callback support in the platform reporting managers:

  1. https://github.com/mapiacompany/capacitor-codepush/blob/main/ios/Plugin/CodePushReportingManager.m#L36
  2. https://github.com/mapiacompany/capacitor-codepush/blob/main/android/src/main/java/com/microsoft/capacitor/CodePushReportingManager.java#L32

Something like this (I'm not sure of the syntax needed, I think this is wrong but the intent is right.):

if(window.codePush) {
   javascript:document.addEventListener(\"deviceready\", function () { window.codePush.reportStatus(%d, %s, %s, %s, %s, %s); });
} else {
   window.codePushReportStatus = function () { window.codePush.reportStatus(%d, %s, %s, %s, %s, %s); });
}

Then in codePush.ts here: https://github.com/mapiacompany/capacitor-codepush/blob/main/src/codePush.ts#L525

export const codePush = new CodePush();
(window as any).codePush = codePush;
if(window.codePushReportStatus) {
   window.codePushReportStatus();
   window.codePushReportStatus = undefined;
}
```f

from capacitor-codepush.

lincolnthree avatar lincolnthree commented on August 15, 2024

@leo6104 What do you think?

from capacitor-codepush.

lincolnthree avatar lincolnthree commented on August 15, 2024

As a workaround. CodePush needs to be loaded immediately on App start. (I've done this in the Angular root app TypeScript file.) But this is not ideal since it increases the initial JS bundle size and app load times. (Bad for PWAs & user experience.)

import { codePush } from 'capacitor-codepush';
(() => codePush)(); // to prevent it from being minified away

from capacitor-codepush.

o-alexandrov avatar o-alexandrov commented on August 15, 2024

@lincolnthree sorry for pinging about a different issue, but it seems your input might be valuable in #21

  • as it sounds you don't experience this issue on iOS.

Please let us know whether you experience such issue on iOS. It would let us know there whether issue is related to our own setups, or it's not working for everyone.

from capacitor-codepush.

lincolnthree avatar lincolnthree commented on August 15, 2024

@o-alexandrov It does actually happen on iOS. I've amended my issue report.

from capacitor-codepush.

lincolnthree avatar lincolnthree commented on August 15, 2024

@o-alexandrov BTW. It's probably better to actually ping me in the issue you'd like me to look at, rather than convolute the discussion of another topic. The topic you're interested in is unrelated other than the platform is may occur on, which I'm not sure is a really strong 'link'. Lots of platform specific bugs occur in hybrid codebases due to the double coding required to support each platform.

from capacitor-codepush.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.