This must be something obvious, but I don't know what to do. I have added platform references per NS documentation and android.Manifest isn't defined there. What do you use?
I am trying to use this plugin along with the nativescript-contacts one to hack together a quick proof of concept. Currently the contants plugin fails with a permission error on Android 7.1 but works on 4.4, hence my interest in the permissions plugin.
import { Observable } from 'data/observable';
var app = require("application");
var contacts = require("nativescript-contacts");
var permissions = require("nativescript-permissions");
export class HelloWorldModel extends Observable {
// tap first
onTap2() {
permissions.requestPermission(android.Manifest.permission.READ_CONTACTS, "I need these permissions because I'm cool")
.then(function () {
console.log("Woo Hoo, I have the power!");
})
.catch(function () {
console.log("Uh oh, no permissions - plan B time!");
});
}
// tap second
public onTap() {
contacts.getContact().then(function (args) {
/// Returns args:
/// args.data: Generic cross platform JSON object
/// args.reponse: "selected" or "cancelled" depending on wheter the user selected a contact.
console.log('args.response ' + args.response);
if (args.response === "selected") {
var contact = args.data; //See data structure below
// lets say you wanted to grab first name and last name
console.log(contact.name.given + " " + contact.name.family);
//lets say you want to get the phone numbers
contact.phoneNumbers.forEach(function (phone) {
console.log(phone.value);
});
//lets say you want to get the addresses
contact.postalAddresses.forEach(function (address) {
console.log(address.location.street);
});
}
});
}
}
$ tns info
All NativeScript components versions information
┌──────────────────┬─────────────────┬────────────────┬─────────────┐
│ Component │ Current version │ Latest version │ Information │
│ nativescript │ 3.0.3 │ 3.0.3 │ Up to date │
│ tns-core-modules │ 3.0.1 │ 3.0.1 │ Up to date │
│ tns-android │ 3.0.1 │ 3.0.1 │ Up to date │
│ tns-ios │ 3.0.1 │ 3.0.1 │ Up to date │
└──────────────────┴─────────────────┴────────────────┴─────────────┘
I would recommend you read my blog. http://fluentreports.com/blog
But in a nutshell, you need to either globally define android as an or prefix it in a single use (<any>android). as and .
This must be something obvious, but I don't know what to do. I have added platform references per NS documentation and
android.Manifest
isn't defined there. What do you use?I am trying to use this plugin along with the nativescript-contacts one to hack together a quick proof of concept. Currently the contants plugin fails with a permission error on Android 7.1 but works on 4.4, hence my interest in the permissions plugin.