Skip to content

Commit

Permalink
Added method: exitApp()
Browse files Browse the repository at this point in the history
  • Loading branch information
hmphu committed May 24, 2023
1 parent 6fe71b3 commit 95a84a6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ npx cap sync
* [`isJailbrokenOrRooted()`](#isjailbrokenorrooted)
* [`isSimulator()`](#issimulator)
* [`isDebuggedMode()`](#isdebuggedmode)
* [`exitApp()`](#exitapp)
* [Interfaces](#interfaces)

</docgen-index>
Expand Down Expand Up @@ -56,6 +57,15 @@ isDebuggedMode() => Promise<JailbreakRootResult>
--------------------


### exitApp()

```typescript
exitApp() => void
```

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


### Interfaces


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,16 @@ public void isDebuggedMode(PluginCall call) {
ret.put("result", implementation.isDebuggedMode(result));
call.resolve(ret);
}

@PluginMethod
public void exitApp(PluginCall call) {
unsetAppListeners();
call.resolve();
getBridge().getActivity().finish();
}

private void unsetAppListeners() {
bridge.getApp().setStatusChangeListener(null);
bridge.getApp().setAppRestoredListener(null);
}
}
1 change: 1 addition & 0 deletions ios/Plugin/CapacitorJailbreakRootDetectionPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
CAP_PLUGIN_METHOD(isJailbrokenOrRooted, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(isSimulator, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(isDebuggedMode, CAPPluginReturnPromise);
CAP_PLUGIN_METHOD(exitApp, CAPPluginReturnNone);
)
8 changes: 8 additions & 0 deletions ios/Plugin/CapacitorJailbreakRootDetectionPlugin.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import Capacitor
import UIKit

/**
* Please read the Capacitor iOS Plugin Development Guide
Expand All @@ -26,4 +27,11 @@ public class CapacitorJailbreakRootDetectionPlugin: CAPPlugin {
"result": UIDevice.current.isDebuggedMode
])
}

@objc func exitApp(_ call: CAPPluginCall) {
UIControl().sendAction(#selector(NSXPCConnection.suspend), to: UIApplication.shared, for: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
exit(EXIT_SUCCESS)
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@evehr/capacitor-jailbreak-root-detection",
"version": "4.0.1",
"version": "4.0.2",
"description": "Jailbreak Root detection plugin for capacitor.",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down
1 change: 1 addition & 0 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface CapacitorJailbreakRootDetectionPlugin {
isJailbrokenOrRooted(): Promise<JailbreakRootResult>;
isSimulator(): Promise<JailbreakRootResult>;
isDebuggedMode(): Promise<JailbreakRootResult>;
exitApp(): void;
}

export interface JailbreakRootResult {
Expand Down
4 changes: 4 additions & 0 deletions src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export class CapacitorJailbreakRootDetectionWeb
extends WebPlugin
implements CapacitorJailbreakRootDetectionPlugin
{
exitApp(): void {
// Do Nothing
}

async isJailbrokenOrRooted(): Promise<JailbreakRootResult> {
return {
result: false,
Expand Down

0 comments on commit 95a84a6

Please sign in to comment.