ie9 not supporting geolocation? - geolocation

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.

Related

Geolocation API in IE11

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!

Are Web Notifications Supported on Microsoft Edge Mobile?

Recently I heard that Microsoft Edge mobile supports Web Notifications after the Windows 10 Anniversary Update. So I tried the following code but it didn't work.
if ( window.Notification && Notification.permission !== "denied" ) {
Notification.requestPermission( function( status ) { // status is "granted", if accepted by user
var n = new Notification('Title', {
body: 'I am the body text!',
icon: '/path/to/icon.png' // optional
});
});
}
I am on Windows 10 mobile using Edge 38.14393.67.0, and EdgeHTML 14.14393.
I tried to use it too, and I get instant denied response. I've made a ticket about this in the feedback hub.
(Update)
I've found their answer here. https://github.com/MicrosoftEdge/MicrosoftEdge-Documentation/issues/62
So yes, it would be quite limited, but still. They say it's supported.
https://developer.microsoft.com/en-us/microsoft-edge/platform/status/webnotifications/

Login through Twitter and Google Plus in Appcelerator Studio

It been two days I'm working with twitter and google plus Signup/Signin but unfortunately unable to hit it.
For twitter, I tried Aaron K Saunders's test app https://github.com/aaronksaunders/test_social. It says "You've granted access to your app. Next, return to your app and enter this PIN (XXXXXXX) to complete authentication process". What really is that??? I'm confused in it.
For google plus, I tried Google Auth for Titanium test app https://github.com/ejci/Google-Auth-for-Titanium. But it shows simple white screen.
I'm stuck into both of these. Can anyone please help. I'd be grateful.
Thanks a lot!!
I believe you posted this issue on Test Social's GitHub page? Here's what I had to do to get Twitter working on Android - Test Social still works as intended on iOS.
"I have the same issue (Android only, iOS still works as before). This is an issue with Android, not this module. Here is how I go about fixing this on Android.
getHtml on the webView is returning null in Android, but again fine in iOS - Just putting this out there in case anybody runs into this error. Doesn't seem to be a fault of this module.
I modified the authorizeUICallback function inside Test Social:
function authorizeUICallback(e) {
var promptView = Ti.UI.createView({
width:'30%',
height:'10%',
layout: "vertical",
backgroundColor:'black',
bottom:"20%"
}),
pinField = Ti.UI.createTextField({
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
hintText: 'Enter PIN'
}),
pinButton = Ti.UI.createButton({
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
title: "Authorize"
});
promptView.add(pinField);
promptView.add(pinButton);
view.add(promptView);
pinButton.addEventListener('click', function() {
if (!pinField.value) {
alert('No PIN found');
} else {
pin = pinField.value;
response = 1;
response ? ( pin = pinField.value, /*pin = response.split("<code>")[1].split("</code>")[0]*/ destroyAuthorizeUI(), receivePinCallback()) : (loadingView && loadingView.hide(), loadingContainer && loadingContainer.hide(), webView && webView.show()), loading = !1, clearInterval(intervalID), estimates[estimateID] = (new Date).getTime() - startTime, Ti.App.Properties.setString("Social-LoadingEstimates", JSON.stringify(estimates));
}
});
}
There was another issue created on the GitHub page and they haven't found a solution either. This seems to be the only way to get Twitter to work with Test Social (or the ONLY way I've found to get it to work with Appcelerator at all).
I can't help you with Google+ just yet. I'm looking to implement that later, but it's not super high on my priority list with their recent changes... Who knows how much longer people will be using it, but I digress... Are you getting any kind of error in the console when you get a 'white screen'?

Binding Energize.js clicks to Google Analytics PhoneGap Build plugins

I'm writing an app using PhoneGap Build, jQuery Mobile and Energize.js (to speed up clicks)
My wish is to bind an 'event' to the Google Analytics plugin for PhoneGap Build, so that I can track user clicks.
As you can see below, my tracking listener is bound to a 'touchstart' event. At the moment, none of the tracking is working. I am unsure if it is because I have bound to an incorrect action (which Energize.js may have changed) or if there is another issue in my code.
Any help would be appreciated. My account on Google Analytics is set as a 'Webpage' instead of 'Mobile App' as per the plugin guidelines.
$(document).on("touchstart", ".condition-list-item a", function() {
var deviceID = device.platform + '.' + device.uuid;
// Generates unique variable for each device
var conditionVar = $(this).attr("data-condition");
// Pulls ConditionName from list item clicked
PageButtonClicked(conditionVar);
// Fires 'Page' tracking to Google Analytics, with ConditionName as 'Page'
VariableButtonClicked(deviceID, conditionVar)
navigator.geolocation.getCurrentPosition(onSuccess);
// Creates an object 'Position' using Geolocation API
function onSuccess(position) {
var geo = position.coords.latitude + ', ' + position.coords.longitude;
}
});
Try this:
$(document).ready(function(){
$(".condition-list-item a").on("touchstart", function(e){
//your function
});
});
As follow-up, the above code is still not working. Google Analytics is currently attempting to track the information as if it were a website (as recommended by the plugin).
I change the settings on the Google Analytics website to track as if it were a Mobile App. I still think the above code is not working; however, Google Analytics' built in tracking takes care of much the same stuff and is working beautifully.

JQuery AJAX call to web on iOS stopped working using Phonegap web app

I have an app written in HTML5, Javascript, css3 using PhoneGap to compile for iOS and Android. It collects survey information and uploads this via Ajax call to online host. It has been working really well until recently the upload code appeared to stop working. WELL NOT QUITE! On the iPad it says successful but in fact nothing ever makes it to the host. This is VERY strange. I've tried re-writing the Ajax call based on articles on here but no luck.
iOS - 6.1.3, PhoneGAP 2.7.0, PhoneGap/Adobe Build used.
This is the upload piece...
function sendToWeb(){
var errorflag = false;
db.transaction(function (tx) {
tx.executeSql("SELECT weburl FROM settings", [], function(tx, results){
var webURL = results.rows.item(0).weburl;
tx.executeSql("SELECT * FROM surveypretransfer WHERE uploaded = '0'",[], function(tx, results){
if (results.rows.length == 0) {
alert("You have no surveys waiting to upload");
} else {
alert("You have " + results.rows.length + " surveys waiting to upload");
for (var i=0; i < results.rows.length; i++) {
var responseURL = webURL + "/feeds/saveinfo.php";
var responseString = results.rows.item(i).responsestring;
var localid = results.rows.item(i).id;
//alert(localid);
$.ajax({
type: 'POST',
data: responseString,
url: responseURL,
timeout: 30000,
success: function(data) {
alert('Success!' + data.join('\n'));
},
error: function(data) {
alert(data.join('\n'));
console.log("Results: " + localid);
alert("Error during Upload. Error is: "+ data.statusText);
}
}); //ajax
}; //for loop
alert("You have successfully uploaded "+ results.rows.length + " survey results");
tx.executeSql("UPDATE surveypretransfer SET uploaded = '1' WHERE uploaded = '0'");
}; //if statement
}); //tx.execute
});
}, errorCB);
}
Neither of the two alerts fire when loaded on iPad. Works fine on Android and has previously worked on iPad so I can't find what has changed.
UPDATE: Appears that this only applies to WiFi only iPads. All the 3G ones I tested were fine. Figure that!
Config.XML contains app id = "com.mydomain.myapp" (as an example)
URL for upload is "http://customer.mydomain.com/feeds/saveinfo.php?..."
Also added line 'access origin="http://mydomain.com" subdomains="true" '
Still no results. Is anyone seeing/having similar issues? Anyone see my mistake?
For iOS you might want to try <access origin="http://*.mydomain.com" />, as iOS is not documented in the PhoneGap API to support the subdomain property.
If that doesn't solve your issues, you will probably want to look into CORS (Cross Origin Resource Sharing). I had issues trying to do a POST request from my app to a local port on iOS. The W3C has a great article on how to enable CORS that will probably help. I know in my case, the system would attempt to do an OPTIONS request first, and if it didn't work, the whole thing would fail.
Another tool that you will probably find useful (if not now, in the future) is Fiddler. You can set up an iPad to proxy through your desktop, and then you will be able to observe all of the requests going to and from the device. This is how I found the OPTIONS request noted above.

Resources