Reputation: 31
calling
window.addEventListener("deviceorientation", function (event) {
console.log(event);
});
won't work anymore without getting "DeviceOrientationEvent.requestPermission()" before the call, which is a new w3c implementation but doesn't work with ionic Cordova yet(?).
Any ideas?
Upvotes: 1
Views: 775
Reputation: 31
I answer it myself:
this is only basic, no handle to promt the iOS dialog to allow permission again included. If user once decided to "not allow" gyroscope there is no handling.
Right now within typescript it is not possible to call the JS function requestPermission(), so you simple would include a JS File with
var requestOrientationPermit = function() {
DeviceOrientationEvent.requestPermission();
}
and then in the angular ionic ts file
declare var requestOrientationPermit : any;
// ...
// (in some typescript onclick event! call:)
requestOrientationPermit();
// ...
// later...
window.addEventListener("deviceorientation", function (event) {
console.log(event);
.
});
Upvotes: 2