Skip to content

Instantly share code, notes, and snippets.

@Pushplaybang
Created April 27, 2016 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pushplaybang/5f947e1d348ff7c4c9c584ee2362deb4 to your computer and use it in GitHub Desktop.
Save Pushplaybang/5f947e1d348ff7c4c9c584ee2362deb4 to your computer and use it in GitHub Desktop.
Cordova Device Permissions
/*
Example invoking device permissions using the cordova diagnostic plugin
https://github.com/dpa99c/cordova-diagnostic-plugin
*/
// with meteor on mobile this fires onDeviceReady
Meteor.startup(function() {
// This only checks on app startup, ideally it should be functionality specifct
if (Meteor.isCordova) {
// check and request microphone access
cordova.plugins.diagnostic.getMicrophoneAuthorizationStatus(function(status) {
if (status !== "GRANTED") {
// if we don't have them request em.
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function(status) {
//... do something
return;
});
}
}, function() {
throw new Meteor.error('failed to get permission for microphone');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment