I'm attempting to use HTML5 Geolocation on IE11, but despite allowing location permission, I get an error, "This site does not have permission to use the Geolocation API."
To replicate:
Open any site in IE11 (I'm user browerstack to emulate a Windows 10)
Copy/paste the following code in the console:
var options = {
enableHighAccuracy: false,
timeout: 1000000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('got your position');
}
function error(err) {
console.log(err);
}
navigator.geolocation.getCurrentPosition(success, error, options);
Click "Allow Once" when the location prompt appears
Observe the Resulting Error Message, "This site does not have permission to use the Geolocation API."
My browserstack is running IE11 version 11.1.17134.0, on a Windows 10.
Thanks in advance for your help!
Related
I'm using navigator.geolocation.getCurrentPosition() in react native and it's working fine.
But i would like to be able to react nicely if location services are turned off (a dialog box that leads the user to settings).
I found that plugin for android and i think it's going to work fine :
https://www.npmjs.com/package/react-native-android-location-services-dialog-box How should i do in iOS ?
EDIT
You can use this very well done 3rd party library
and then use it like this :
Location.getAuthorizationStatus((authorization) => {
console.log(authorization)
});
Previous answer
getCurrentPosition can take an error callback. This will be triggered if the location is not enabled.
You can do something like:
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({ position });
},
(error) => {
console.log(alert);
},
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
You can check the docs for more informations.
I am trying to convert a Chrome Extension to Firefox using the new API WebExtension.
Everything works fine except the use of chrome.runtime.sendMessage() in a webpage. The goal is to communicate with the addon and pass some data.
For that, I am using the property "externally_connectable" as written here : can-a-site-invoke-a-browser-extension
background.js
chrome.runtime.onMessageExternal.addListener(
function(request, sender, sendResponse) {
sendResponse({
success: true,
message: 'ok'
});
return true; // Bug chrome, close channel otherwise
});
In webpage
chrome.runtime.sendMessage(EXTENSION_ID, {type: 'show', data: 'test'}, function(response) {
if (response.success && !response.success) {
console.log(response.message);
}
});
In chrome, the communication works fine but in Firefox, the code executed in the webpage doesn't work : "chrome is not defined".
Is there another var to use instead of "chrome" or is it not implemented ?
I've found nothing about this on the web :( Thanks
Web extensions do not support externally_connectable website scripts but you can communicate between website scripts and extension scripts as shown in this example
https://github.com/mdn/webextensions-examples/tree/master/page-to-extension-messaging
Try use WebExtension APIs with "browser" namespace
browser.runtime.sendMessage(...)
All available APIs on mozilla development
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts#WebExtension_APIs
I'm trying to use Notification Hub to push Cordova app(iOS)
Azure side is as below.
Source code on client side is as below.
I'm sure Azure client is correctly connected and registration is successful.
function initPushNotification(){
var push = PushNotification.init({
android: {
senderID: "12345679"
},
ios: {
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});
var registrationSuccess = function () {
alert('Registered with Azure!');
};
var registrationFailure = function (error) {
alert('Failed registering with Azure: ' + error);
};
push.on('registration', function(data) {
client.push.apns.registerTemplate(handle,
'myTemplate', template, null)
.done(registrationSuccess, registrationFailure);
});
push.on('notification', function(data) {
alert('Push Received: ' + data.message);
});
push.on('error', function(e) {
alert(e.message);
});
But when I execute Test Send from notification hub page, nothing happens.
I tried from simple ruby script to APNS directly and notification comes to iPhone correctly.
Does anyone know how to fix it or any information?
My environment is
MacBook Pro
OS X ElCapitan
Cordova 6.0.0
com.microsoft.azure-mobile-services 1.2.9 "Windows Azure Mobile Services"
phonegap-plugin-push 1.6.2 "PushPlugin"
Most likely the call to client.push.register() is not succeeding for some reason. I'm not using the particular plugin you're using, I'm using azure-mobile-apps-cordova-client combined with phonegap-plugin-push. So far, this combination is working for my purposes.
You can find a more complete example here: Add Push Notifications to your Apache Cordova App.
One thing I would add is that when you call the push.register() API in the azure-mobile-apps-cordova-client plugin, you can give it an error function callback that gets called if the API call fails. It would look like this:
push.register('apns', data.registrationId, null, null, function(err)
{console.log(err);});
Lastly, in Visual Studio, you can also connect to your notification hub and list and manage the registrations. This is useful to determine if the APNS registration is really accepted.
Is there any way to fetch user’s phone number in Firefox OS?
If so, any help would be appreciated.
According to Mozilla's app permissions page, there is an permission called "phonenumberservice" but there is no information about it. Anyway, the permision is listed under the "Internal (Certified) app permissions", which means that, when available, it can only be used by "system-level apps and default apps created by Mozilla/operators/OEMs".
With Firefox 2.0 you should be able to use Mobile Identity API:
https://wiki.mozilla.org/WebAPI/MobileIdentity
https://bugzilla.mozilla.org/show_bug.cgi?id=1021594
I believe the permission is:
"permissions": {
"mobileid": {} }
And it is privileged.
So, as #Jason said, the Mobile Identity API provides this capability, and not just for certified, but for privileged applications. So it is no longer just for OEMs.
The Mozilla Wiki site shows the API:
dictionary MobileIdOptions {
boolean forceSelection = false;
};
partial interface Navigator {
Promise getMobileIdAssertion(optional MobileIdOptions options);
};
The site also provides a sample code skeleton for this:
function verifyAssertion(aAssertion) {
// Make use of the remote verification API
// and return the verified msisdn.
// NB: This is necessary to make sure that the user *really* controls this phone number!
}
// Request a mobile identity assertion and force the chrome UI to
// allow the user to change a possible previous selection.
navigator.getMobileIdAssertion({ forceSelection: true })
.then(
(assertion) => {
verifyAssertion(assertion)
.then(
(msisdn) => {
// Do stuff with the msisdn.
}
);
},
(error) {
// Process error.
};
);
For this to work, you need to add the mobileid permission in the manifest file, for example like this (I made up the description):
"permissions": {
"mobileid": {
"description": "Required for sending SMS for two factor authentication",
"access": "readonly"
}
}
PS: I made this answer, because most answers are outdated, and the one that isn't, does not contain all useful information.
References:
App Manifest Documentation
Firefox Remote Verification
Greetings Everyone,
I am creating a web application that uses the Geolocation API to locate the end user. It works great on almost every platform I can think of except for Internet Explorer 9. Things get a little stranger though. If I have my Google Toolbar loaded into my Internet Explorer browser window, everything sails smoothly. Here is the offending chunk of code that I have been working with:
if (navigator.geolocation) {
var locationMarker = null;
navigator.geolocation.watchPosition(
function( position ){
var point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
if (!locationMarker) {
locationMarker = addMarker(
position.coords.latitude,
position.coords.longitude,
"Initial Position"
);
}
else{
updateMarker(
locationMarker,
position.coords.latitude,
position.coords.longitude,
"Updated / Accurate Position"
);
};
map.setCenter(point);
if (map.zoom < 17){
map.setZoom(17);
};
},
function( error ){
console.log( "Something went wrong: ", error );
},
{
timeout: (5 * 1000),
maximumAge: (1000 * 60 * 15),
enableHighAccuracy: true
}
);
}
else {
alert("Geolocation is not supported by this browser");
}
Whenever I access my application with Internet Explorer 9 I get the "Geolocation is not supported by this browser" alert. That is unless I have my Google Toolbar active. If the Google Toolbar is active however, then the Google Toolbar handles the permissions.
How do I get geolocation to work in IE9? My application works flawlessly in Safari, Firefox, Chrome, iOS and Android. I am totally stumped.
Thanks, Tyler Waring
user1303379,
IE9 and IE10 both support geolocation, however earlier versions of IE do not support it ( reference http://caniuse.com/#feat=geolocation ). Here is a blog post by IE about geolocation in IE9 http://blogs.msdn.com/b/ie/archive/2011/02/17/w3c-geolocation-api-in-ie9.aspx and here is a test page using navigator.geolocation.watchPosition like you are above.
For browsers that don't support geolocation you may consider using one of the geolocation polyfills listed here https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills
IE9 & IE10 ask the user if they would like to share their location http://cl.ly/image/0X0o2F0s1N03 My guess is that you may have denied access to your location at some point.
The Google Toolbar added a feature to determine geolocation back in the IE8 days http://googletoolbarhelp.blogspot.com/2010/02/google-toolbar-6413211732-for-ie.html From what you describe it sounds like the Google Toolbar started to provide geolocation since the native IE9 geolocation was denied access.