Detecting root access in an Ionic 2 app using TypeScript

I am currently in the process of developing a mobile application using ionic2. One of the requirements for my app is to check if an android device has been rooted. I conducted some research online and came across a plugin called this plugin known as cordova-plugin-root-detection, however, it doesn't seem to be working for me.

Following the instructions provided in the link above, I added this plugin to my project using the following command:

cordova plugin add https://github.com/trykovyura/cordova-plugin-root-detection.git

Even after adding the plugin, I encountered issues while trying to import it, receiving an error message indicating that no module was present. In an attempt to resolve this, I force quit my project, ran npm install, and reopened my project, but unfortunately, the error persisted.

rootDetection.isDeviceRooted(successCallback, errorCallback);

Despite calling this function, it seems that the module is still not present.

If anyone has any references or suggestions regarding this plugin, your input would be greatly appreciated.

Answer №1

Bypass the need to import the plugin through Typescript and instead, utilize direct access via the global object window.

(<any>window).plugins.rootDetection.isDeviceRooted(successCB, errorCB)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Leveraging Inversify for implementing a Multiinject functionality for a class with both constant and injected parameters

In my Typescript code, I have an insuranceController class that takes a multi inject parameter: @injectable() export class InsuranceController implements IInsuranceController { private policies: IInsurancePolicy[]; constructor(@multiInject("IInsu ...

Encountering issues with material 2 autoComplete onSelect() function after transitioning to Angular4

I recently made the transition to Angular 4 and material 2, but I'm encountering an issue with the autoComplete's onSelect() on md-option. It seems to be not working anymore and I can't seem to find any relevant documentation. Has anyone els ...

Is there a way to utilize an Angular Material checkbox without any extra gaps or spacing?

Currently, I am working with Angular Material and trying to figure out how to remove the default spacing around the checkbox. The checkboxes in Angular Material are typically surrounded by some space (as shown in the image). Is there a simple way to elimin ...

Unable to retrieve the updated value from the service variable

I'm attempting to implement a filter that allows me to search for items based on a service variable that is updated with user input. However, I am only able to retrieve the initial value from the service in my component. Service HTML (whatever is typ ...

Can you explain the distinction between needing ts-node and ts-node/register?

Currently, I am conducting end-to-end tests for an Angular application using Protractor and TypeScript. As I was setting up the environment, I came across the requirement to include: require("ts-node/register") Given my limited experience with Node.js, I ...

The variance between executing code with and without breakpoints in JUnit using Selenium's Chrome Driver

My goal is to complete the sign-in page and then use selenium to navigate to a custom form. Everything seems to be working fine when I have a break point set, but as soon as I remove it, the session gets cleared out. The Angular authentication mechanism re ...

Angular component testing encountering undefined NgZone

I am facing a challenge while testing for bad input values in an Angular Date Range picker component that I am developing. In my ngOnInit() function, I include a check for minimum and maximum date values. However, when attempting to write a test case for ...

Error Type: Unable to access the X property because it is undefined

I have this Interface that serves as a type for a JSON file: export interface IIndustrySectors { IndustrySector: string; isSelected: string; dataSubjectCategories:string[]; dataTypeCategories:string[]; SubIndustries:[{ IndustrySector: stri ...

Tips for handling callback responses from API POST requests in Node.js

I have integrated the following API Function into my project: The backend is built using NodeJS and the frontend with Angular. I am struggling to understand how the Callback in the function's POST request works. It seems to require a domain setup an ...

M.E.A.N - Suite for setting up and defining backend boundaries consisting of MongoDB, Express.js, Angular2, node.js

Seeking knowledge on how the frameworks and platforms Angular 2 and Express.js collaborate in the 'mean' approach is my main query. I am interested in understanding where the client-side ends and the server-side begins. After delving into this t ...

Encountering an Unexpected Index Error with ngFor in Angular 4/5

I am struggling to create a list of inputs and I can't seem to get ngFor to work properly. <div *ngFor="let q of questions; let i = index" class="col-3"> <div class="group"> <input [(ngModel)]="q" [class.ng-not-empty]="q.length & ...

Determining the correct type for a recursive function

I have created a function that is capable of recursively traversing through a nested or non-nested object to search for a specific key and extract its value. const findName = <T extends object>(obj: T, keyToFind: string): T[] => { return Object ...

Using Angular: Inject a different function after unsubscribing from the Timer Observable

I'm currently developing an exam app and I'm facing an issue where the view controller is getting stuck in a loop after unsubscribing from the timer. The goal is to notify the user when their time is up and redirect them to a results page. If an ...

Combining the Partial<CssStyleDeclaration> union type with a dictionary can lead to potential typing complications when the implicit any flag is

Using VueJS v-bind:style binding makes it possible to set CSS variables. I am attempting to create a union type that allows for the object passed to v-bind:style to retain typings for CssStyleDeclaration, while also being relaxed enough to accept an arbitr ...

Tips for formatting the return Date when utilizing the setDate() method

I set the end of the week to be the upcoming weekend using the following code snippet this.weekEnd = new Date(this.currentDate.setDate(end)); Now, my goal is to update the weekEnd by adding 7 days to it. I attempted to achieve this as shown below, however ...

What could be the reason for ngOnChanges lifecycle hook not getting invoked?

I am currently experimenting with Angular 2 in an effort to learn more about it. I noticed that ngOnChanges is not triggering in the code below: app.component.ts: import { Component, Input } from "@angular/core" import { FormsModule } from '@angular ...

A guide on creating dynamic field names for trees in TypeScript

Example: interface Tree { [key: string]: Tree | {name: string} } const t: Tree = { b: { name: 'test 1' }, c: { d: { name: 'test 2' } }, e: { f: { g: { name: 'test 3' } ...

Testing a close function in a modal using Karma-jasmine

Testing is new to me and I'm looking to test the close function and see if it renders properly in Angular. Here's the HTML structure: <div class="modal active" *ngIf="active" id="modal"> <div class=" ...

Obtaining Prisma arguments by providing the table name as a string

Is there a way to retrieve the query arguments for a Prisma function by only passing the table name? Currently, I know I can obtain the table by providing the table name as a string in the following manner: function (tablename: string) { await prisma.[tab ...

How can I retrieve response headers in my Angular4 component?

Hello folks, I'm encountering an issue with Angular4. I'm trying to return a response header to my component but it's not working as expected. Here is an example of my component code: this.filmService.create(this.film).subscribe( data =&g ...