Pasha
Pasha

Reputation: 17

NativeScript Does Not Recognize "android.Manifest.permission.READ_CONTACTS"

Hello I am new to mobile development and Angular 2. I am trying to request permission for reading contacts, however NativeScript is not recognizing "android".

For exmple I am not able to run the following code:

permissions.requestPermission(android.Manifest.permission.INTERNET, "I need these permissions because I'm cool");

Error: Cannot find name 'android'.

Any help will be greatly appreciated.

Upvotes: 0

Views: 1056

Answers (1)

Nathanael
Nathanael

Reputation: 5399

At the top of your TS file just add:

declare var android: any;

TypeScript does not know what "android" is; so you have to tell it what it is

The other way to fix this is to download the platform typings https://www.npmjs.com/package/tns-platform-declarations and then install them. Please note the Typings do typically slow down compilation as they add a lot of data that has to be parsed...

Disclaimer: I'm the author of the NativeScript-Permissions plugin you are using. ;-)

Upvotes: 9

Related Questions