-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cordova-plugin-iroot): add plugin (#4857)
- Loading branch information
1 parent
ac767ab
commit 658a55b
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# IRoot | ||
|
||
```text | ||
$ ionic cordova plugin add cordova-plugin-iroot | ||
$ npm install @awesome-cordova-plugins/i-root | ||
``` | ||
|
||
## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/iroot/) | ||
|
||
Plugin Repo: [https://github.com/WuglyakBolgoink/cordova-plugin-iroot](https://github.com/WuglyakBolgoink/cordova-plugin-iroot) | ||
|
||
Use this plugin to add an extra layer of security for your app by detecting if the device was rooted (on android) or jailbreaked (on iOS). | ||
|
||
## Supported platforms | ||
|
||
* Android | ||
* iOS | ||
|
||
## Original Plugin Notes | ||
|
||
### iOS - Postinstall | ||
|
||
To avoid errors like | ||
|
||
> -canOpenURL: failed for URL: "cydia://package/com.example.package" - error: "This app is not allowed to query for scheme cydia" | ||
don’t forget to add `"cydia"` in `LSApplicationQueriesSchemes` key of `info.plist`. Otherwise `canOpenURL` will always return `false`. | ||
|
||
```xml | ||
<xxx> | ||
<key>LSApplicationQueriesSchemes</key> | ||
<array> | ||
<string>cydia</string> | ||
</array> | ||
</xxx> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; | ||
|
||
/** | ||
* @name IRoot | ||
* @description | ||
* Use this plugin to add an extra layer of security for your app by detecting if the device was rooted (on android) or jailbreaked (on iOS). | ||
* | ||
* @usage | ||
* ```typescript | ||
* import { IRoot } from '@awesome-cordova-plugins/i-root'; | ||
* | ||
* constructor(private iRoot: IRoot) { } | ||
* | ||
* ... | ||
* | ||
* this.iRoot.isRooted() | ||
* .then((res: boolean) => console.log('is rooted?', res)) | ||
* .catch((error: string) => console.error(error)); | ||
* | ||
* this.iRoot.isRootedWithBusyBox() | ||
* .then((res: boolean) => console.log('is rooted?', res)) | ||
* .catch((error: string) => console.error(error)); | ||
* ``` | ||
*/ | ||
@Plugin({ | ||
pluginName: 'IRoot', | ||
plugin: 'cordova-plugin-IRoot', | ||
pluginRef: 'IRoot', | ||
repo: 'https://github.com/WuglyakBolgoink/cordova-plugin-IRoot', | ||
platforms: ['Android', 'iOS'], | ||
}) | ||
@Injectable() | ||
export class IRoot extends AwesomeCordovaNativePlugin { | ||
/** | ||
* Checks if the device is rooted/jailbroken. | ||
* @return {Promise<boolean>} Resolves to true if the device is Jailbroken/rooted, otherwise false. | ||
*/ | ||
@Cordova() | ||
isRooted(): Promise<boolean> { | ||
return; | ||
} | ||
|
||
/** | ||
* Android only! Checks if the device was rooted via busybox. | ||
* @return {Promise<boolean>} Resolves to true if the device is Jailbroken/rooted, otherwise false. | ||
*/ | ||
@Cordova({ | ||
platforms: ['android'], | ||
}) | ||
isRootedWithBusyBox(): Promise<boolean> { | ||
return; | ||
} | ||
} |