Created
April 27, 2016 22:01
-
-
Save Pushplaybang/5f947e1d348ff7c4c9c584ee2362deb4 to your computer and use it in GitHub Desktop.
Cordova Device Permissions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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