|
| 1 | +import { Injectable } from '@angular/core'; |
| 2 | +import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core'; |
| 3 | + |
| 4 | +/** |
| 5 | + * @name IRoot |
| 6 | + * @description |
| 7 | + * 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). |
| 8 | + * |
| 9 | + * @usage |
| 10 | + * ```typescript |
| 11 | + * import { IRoot } from '@awesome-cordova-plugins/i-root'; |
| 12 | + * |
| 13 | + * constructor(private iRoot: IRoot) { } |
| 14 | + * |
| 15 | + * ... |
| 16 | + * |
| 17 | + * this.iRoot.isRooted() |
| 18 | + * .then((res: boolean) => console.log('is rooted?', res)) |
| 19 | + * .catch((error: string) => console.error(error)); |
| 20 | + * |
| 21 | + * this.iRoot.isRootedWithBusyBox() |
| 22 | + * .then((res: boolean) => console.log('is rooted?', res)) |
| 23 | + * .catch((error: string) => console.error(error)); |
| 24 | + * ``` |
| 25 | + */ |
| 26 | +@Plugin({ |
| 27 | + pluginName: 'IRoot', |
| 28 | + plugin: 'cordova-plugin-IRoot', |
| 29 | + pluginRef: 'IRoot', |
| 30 | + repo: 'https://github.com/WuglyakBolgoink/cordova-plugin-IRoot', |
| 31 | + platforms: ['Android', 'iOS'], |
| 32 | +}) |
| 33 | +@Injectable() |
| 34 | +export class IRoot extends AwesomeCordovaNativePlugin { |
| 35 | + /** |
| 36 | + * Checks if the device is rooted/jailbroken. |
| 37 | + * @return {Promise<boolean>} Resolves to true if the device is Jailbroken/rooted, otherwise false. |
| 38 | + */ |
| 39 | + @Cordova() |
| 40 | + isRooted(): Promise<boolean> { |
| 41 | + return; |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Android only! Checks if the device was rooted via busybox. |
| 46 | + * @return {Promise<boolean>} Resolves to true if the device is Jailbroken/rooted, otherwise false. |
| 47 | + */ |
| 48 | + @Cordova({ |
| 49 | + platforms: ['android'], |
| 50 | + }) |
| 51 | + isRootedWithBusyBox(): Promise<boolean> { |
| 52 | + return; |
| 53 | + } |
| 54 | +} |
0 commit comments