mapiacompany / capacitor-codepush

Capacitor plugin for CodePush
http://appcenter.ms
Other
152 stars 64 forks source link

iOS An error occurred when trying to get the hash of the binary contents #27

Closed alexcroox closed 3 years ago

alexcroox commented 3 years ago

Description

iOS, iPhone 12 Mini Simulator + Real Device iPhone 12 Mini

First run, I have deployed several updates to codepush "development" deployment with a target binary of -t '^0.0.0'

appcenter codepush release --app xxx/xxx-xxx -d development -t '^0.0.0' -c dist/

and I initialise it like this:

if (isNative) {
    const { codePush } = await import('capacitor-codepush')
    const { App } = await import('@capacitor/app')

    otaUpdates.sync = () => {
      $log.debug('OTA: Running sync')

      codePush.sync({
        installMode: 'ON_NEXT_RESUME'
      })
    }

    // When the app is brought back to the foreground, let's check for an update
    App.addListener('appStateChange', ({ isActive }) => {
      $log.debug('Native app state changed. Is active?', isActive)

      if (isActive) {
        otaUpdates.sync()
      }
    })

    // Run on first launch
    otaUpdates.sync()
}

Reproduction

⚡️  [log] - OTA: Running sync
⚡️  To Native ->  CodePush notifyApplicationReady 126941029
⚡️  TO JS undefined
⚡️  To Native ->  CodePush getDeploymentKey 126941030
⚡️  TO JS {"value":"xxx-hidden-for-issue-xxx"}

⚡️  To Native ->  CodePush getServerURL 126941032
⚡️  TO JS {"value":"https:\/\/codepush.appcenter.ms\/"}

⚡️  To Native ->  CodePush notifyApplicationReady 126941035

⚡️  To Native ->  CodePush getAppVersion 126941040
⚡️  TO JS {"value":"0.5.0"}

⚡️  To Native ->  CodePush getBinaryHash 126941041
ERROR MESSAGE:  {"errorMessage":"An error occurred when trying to get the hash of the binary contents. ","message":"An error occurred when trying to get the hash of the binary contents. "}

⚡️  [error] - {"errorMessage":"An error occurred when trying to get the hash of the binary contents. ","message":"An error occurred when trying to get the hash of the binary contents. "}
⚡️  [error] - [CodePush] Could not get binary hash.Error: Could not get binary hash. 

⚡️  To Native ->  CodePush getAppVersion 126941042
⚡️  TO JS {"value":"0.5.0"}

Additional Information

    "@capacitor-community/http": "1.0.0-alpha.3",
    "@capacitor/android": "3.0.0-rc.0",
    "@capacitor/app": "0.3.6",
    "@capacitor/browser": "0.4.6",
    "@capacitor/camera": "0.4.3",
    "@capacitor/core": "3.0.0-rc.0",
    "@capacitor/device": "0.5.6",
    "@capacitor/dialog": "0.4.6",
    "@capacitor/ios": "3.0.0-rc.0",
    "@capacitor/keyboard": "0.5.6",
    "@capacitor/push-notifications": "0.3.6",
    "@capacitor/splash-screen": "0.3.6",
    "@capacitor/status-bar": "0.4.6",
alexcroox commented 3 years ago

Actually I don't think this is a fatal error, looking at:

https://github.com/mapiacompany/capacitor-codepush/blob/main/src/localPackage.ts#L513

It seems it's just using the logError method to warn when it can't find it on first run of the app