mapiacompany / capacitor-codepush

Capacitor plugin for CodePush
http://appcenter.ms
Other
151 stars 65 forks source link

Can not use `sync` method in script #61

Closed sawaca96 closed 2 years ago

sawaca96 commented 2 years ago

Description

I want to use CodePush in index.html. But error occurred : Unhandled Promise Rejection: Error: "CodePush.sync()" is not implemented on iOS

<script src="capacitor.js"></script>
<script>
async function onLoad() {
  const { Plugins } = Capacitor;
  const { CodePush } = Plugins;
  document.addEventListener(
    'deviceready',
    async function () {
      await CodePush.sync()
    },
    false
  );
  document.addEventListener(
    'resume',
    function () {
      ...
    },
    false
  );
  document.addEventListener(
    'pause',
    function () {
      ...
    },
    false
  );
}
</script>
...
<body onload="onLoad()">

So I checked CodePush object but there is no sync method. also API is different from docs.

image

How can I solve this ?

Additional Information

I use vue2 and capacitor3

alexcroox commented 2 years ago

const { CodePush } = Plugins;

That doesn't look like Capacitor 3 code to me

sawaca96 commented 2 years ago

@alexcroox then how to use CodePush in index.html ? any suggestion or example ?

tolutronics commented 2 years ago

//capacitor v3 import { codePush } from 'capacitor-codepush';

sawaca96 commented 2 years ago

Can't I use CodePush like the comment?

tolutronics commented 2 years ago

That style is for capacitor version 2, but unfortunately, code push does not support capacitor version 2

alexcroox commented 2 years ago

@sawaca96 I had that Error: "CodePush" plugin is not implemented on ios error because although I had:

@capacitor/device, @capacitor/dialog, @capacitor/filesystem installed, I forgot to run npx cap sync after.

sawaca96 commented 2 years ago

That style is for capacitor version 2, but unfortunately, code push does not support capacitor version 2

Oh, Thanks.

@alexcroox now I use codepush like below

import { codePush, InstallMode } from @capacito-codepush
...
await codePush.sync({
  installMode: InstallMode.ON_NEXT_RESUME
})