Skip to content

Commit

Permalink
feat(app): return promise in exitApp (#777)
Browse files Browse the repository at this point in the history
Co-authored-by: jcesarmobile <[email protected]>
  • Loading branch information
Martin DONADIEU and jcesarmobile authored Mar 1, 2022
1 parent fe601a5 commit 38e1efc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ const checkAppLaunchUrl = async () => {
### exitApp()

```typescript
exitApp() => never
exitApp() => Promise<void>
```

Force exit the app. This should only be used in conjunction with the `backButton` handler for Android to
exit the app when navigation is complete.

Ionic handles this itself so you shouldn't need to call this if using Ionic.

**Returns:** <code>never</code>

**Since:** 1.0.0

--------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void handleOnBackPressed() {
@PluginMethod
public void exitApp(PluginCall call) {
unsetAppListeners();
call.resolve();
getBridge().getActivity().finish();
}

Expand Down
2 changes: 1 addition & 1 deletion app/ios/Plugin/AppPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Define the plugin using the CAP_PLUGIN Macro, and
// each method the plugin supports using the CAP_PLUGIN_METHOD macro.
CAP_PLUGIN(AppPlugin, "App",
CAP_PLUGIN_METHOD(exitApp, CAPPluginReturnNone);
CAP_PLUGIN_METHOD(exitApp, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(getInfo, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(getLaunchUrl, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(getState, CAPPluginReturnPromise);
Expand Down
2 changes: 1 addition & 1 deletion app/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export interface AppPlugin {
*
* @since 1.0.0
*/
exitApp(): never;
exitApp(): Promise<void>;

/**
* Return information about the app.
Expand Down
2 changes: 1 addition & 1 deletion app/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class AppWeb extends WebPlugin implements AppPlugin {
);
}

exitApp(): never {
exitApp(): Promise<void> {
throw this.unimplemented('Not implemented on web.');
}

Expand Down

0 comments on commit 38e1efc

Please sign in to comment.