Skip to content

Commit

Permalink
fix: better res on notify function
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Aug 24, 2023
1 parent cc4a28e commit c5e49a4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@ Capacitor Updator works by unzipping a compiled app bundle to the native device
### notifyAppReady()

```typescript
notifyAppReady() => Promise<BundleInfo>
notifyAppReady() => Promise<{ bundle: BundleInfo; }>
```

Notify Capacitor Updater that the current bundle is working (a rollback will occur of this method is not called on every app launch)
By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.
Change this behaviour with {@link appReadyTimeout}

**Returns:** <code>Promise&lt;<a href="#bundleinfo">BundleInfo</a>&gt;</code>
**Returns:** <code>Promise&lt;{ bundle: <a href="#bundleinfo">BundleInfo</a>; }&gt;</code>

--------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ public void notifyAppReady(final PluginCall call) {
Log.i(CapacitorUpdater.TAG, "semaphoreReady countDown");
this.semaphoreDown();
Log.i(CapacitorUpdater.TAG, "semaphoreReady countDown done");
final JSObject ret = new JSObject();
ret.put("bundle", bundle.toJSON());
call.resolve(ret);
call.resolve();
} catch (final Exception e) {
Log.e(
Expand Down
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ See the Github [Readme](https://github.com/Cap-go/capacitor-updater) for more in
## notifyAppReady()

```typescript
notifyAppReady() => Promise<BundleInfo>
notifyAppReady() => Promise<{ bundle: BundleInfo; }>
```

Notify Capacitor Updater that the current bundle is working (a rollback will occur of this method is not called on every app launch)
By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.
Change this behaviour with {@link appReadyTimeout}

**Returns:** <code>Promise&lt;<a href="#bundleinfo">BundleInfo</a>&gt;</code>
**Returns:** <code>Promise&lt;{ bundle: <a href="#bundleinfo">BundleInfo</a>; }&gt;</code>

--------------------

Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/CapacitorUpdaterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public class CapacitorUpdaterPlugin: CAPPlugin {
let version = self.implementation.getCurrentBundle()
self.implementation.setSuccess(bundle: version, autoDeletePrevious: self.autoDeletePrevious)
print("\(self.implementation.TAG) Current bundle loaded successfully. ['notifyAppReady()' was called] \(version.toString())")
call.resolve()
call.resolve(["bundle": bundle.toJSON()])
}

@objc func setMultiDelay(_ call: CAPPluginCall) {
Expand Down
4 changes: 2 additions & 2 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ export interface CapacitorUpdaterPlugin {
* By default this method should be called in the first 10 sec after app launch, otherwise a rollback will occur.
* Change this behaviour with {@link appReadyTimeout}
*
* @returns {Promise<BundleInfo>} an Promise resolved directly
* @returns {Promise<{ bundle: BundleInfo }>} an Promise resolved directly
* @throws An error if something went wrong
*/
notifyAppReady(): Promise<BundleInfo>;
notifyAppReady(): Promise<{ bundle: BundleInfo }>;

/**
* Download a new bundle from the provided URL, it should be a zip file, with files inside or with a unique id inside with all your files
Expand Down
4 changes: 2 additions & 2 deletions src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export class CapacitorUpdaterWeb
error: "Cannot getChannel in web",
};
}
async notifyAppReady(): Promise<BundleInfo> {
async notifyAppReady(): Promise<{bundle: BundleInfo}> {
console.warn("Cannot notify App Ready in web");
return BUNDLE_BUILTIN;
return {bundle: BUNDLE_BUILTIN};
}
async setMultiDelay(options: {
delayConditions: DelayCondition[];
Expand Down

0 comments on commit c5e49a4

Please sign in to comment.