Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iRoot is not defined, 2nd time launch the app #7

Closed
Piraban opened this issue Apr 30, 2018 · 9 comments
Closed

iRoot is not defined, 2nd time launch the app #7

Piraban opened this issue Apr 30, 2018 · 9 comments

Comments

@Piraban
Copy link

Piraban commented Apr 30, 2018

I have done as a blow

declare var IRoot: any;

ngOnInit() {
   if (typeof (IRoot) !== 'undefined' && IRoot) {
       IRoot.isRooted((data) => {
           if (data && data == 1) {
              this.isRootedORJailBreak = true
              console.log("*******This is routed device");
         } else {
             this.isRootedORJailBreak = false
            console.log("*******This is not routed device");
        }
    }, (data) => {
            this.isRootedORJailBreak = false
           console.log("*******routed device detection failed case", data);
    });
} }

The first time launch app, this is working, after that remove the app from a session, then launch the app, it says 'iRoot is not defined'

Please any help/solution. I am struggling to find a solution more than 3 days.

@WuglyakBolgoink
Copy link
Owner

Hallo @Piraban

I check this asap. Thanks for report.

@Piraban
Copy link
Author

Piraban commented Apr 30, 2018

Seems this is an issue in this plugin. May I know this can be resolved asap?

@Piraban Piraban changed the title Root is not defined, 2nd time launch the app iRoot is not defined, 2nd time launch the app Apr 30, 2018
@WuglyakBolgoink
Copy link
Owner

WuglyakBolgoink commented Apr 30, 2018

@Piraban so... it work good on my test project:

you should wrap your call with document.addEventListener("deviceready", function () {...}), because you try to access plugin before cordova was fully loaded (see http://cordova.apache.org/docs/en/7.x/cordova/events/events.html#deviceready)

import {Component, OnInit} from '@angular/core';

declare var IRoot: any;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = 'app';
  isRootedORJailBreak: boolean;

  ngOnInit() {
    document.addEventListener("deviceready", function () {
      if (typeof (IRoot) !== 'undefined' && IRoot) {
        IRoot.isRooted((data) => {
          if (data && data === 1) {
            this.isRootedORJailBreak = true
            alert("*******This is routed device");
          } else {
            this.isRootedORJailBreak = false
            alert("*******This is not routed device");
          }
        }, (data) => {
          this.isRootedORJailBreak = false
          alert("*******routed device detection failed case: " + JSON.stringify(data, null, 2));
        });
      }
    }, false);
  }
}

@Piraban
Copy link
Author

Piraban commented May 1, 2018

Thanks a lot for the quick fix. I am using ionic 3. I will check and update you.

But in ionic i have used platform ready

ngOnInit(){
      this._platform.ready().then(() => {
          if (typeof (IRoot) !== 'undefined' && IRoot) {
            console.log("********isDeviceRootedJailBreak*2********")
            IRoot.isRooted((data) => {
              if (data && data == 1) {
                console.log("***********IOS JAILBREAKE******YES*****This is routed device**");
                this.isRootedORJailBreak = true
                this._alertServices.alertDialogShow("", "Jailbreak is detected on your device. Sorry you can't access our app");
              } else {
                this.isRootedORJailBreak = false
                console.log("***********IOS JAILBREAKE****NO**This is not routed device*******");
                this.goNextScreen();
              }
            }, (data) => {
              console.log("**********rooted device detection failed case", data);
              this.goNextScreen();
            });
          } else {
            console.log("********IRoot null*1********" + this.isRootedORJailBreak)
            if (this.isRootedORJailBreak) {

            }
          }

        });

      } 

This one didn't work. same issue

@SujitSingh
Copy link

@Piraban which version of this plugin are you using? Look at way of implementation in Ionic.

@WuglyakBolgoink
Copy link
Owner

@Piraban any news?

@ahmed-nabil-elagder
Copy link

ahmed-nabil-elagder commented Oct 10, 2019

a simple note
Instead of using the following check:
if (data && data === 1)

We should use the following check:
if (data && data === true)

@bhargavas12
Copy link

@Piraban Is this issue resolved?
I am still getting undefined value for iRoot.

@WuglyakBolgoink
Copy link
Owner

@bhargavas12 this was already fixed. What do you do exactly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants