Is it possible to use geolocation without asking user permissions? - geolocation

I have read all the posts relating to this probelm, but none of them seem to match my request close enough to help me.
I have a weather widget on a website which uses geolocation to determine the location, is it possible to automatically grant permission without the user being asked for permission?

It is up to the browser to determine whether to provide geolocation information (in the HTML5 sense; after all, you can already determine limited data from their IP address). Whilst there may be some browsers that provide the information silently, none of the mainstream ones default to this behaviour.

Related

Does ServiceWorker send all data to Google or browser vendor?

There are lots of docs about ServiceWorkers, but a very important question remains unanswered:
If my app uses a ServiceWorker, does all data get proxied through Google (or, for non-Chrome, another browser vendor)
If so, what are the privacy implications and mitigations? True, it may be encrypted, but it lets the browser vendor track every time someone uses the app, installs it, etc.
Is there any way to use ServiceWorker without proxying through Google? A privacy mode?
Where is this documented? And why is it kept so secret? It's a major privacy issue and should be made very clear.
No, Service Worker does not send any data to Google or any other browser vendor. It also does not do anything by default or without you asking it to do something.
To put it another way, it does what you tell it to do. It runs code you've written just like the webpage.

Swift - Check if website visited

Is there a method or way in Swift to check if a user has visited a certain webpage or website?
I know a question was asked for this already:
How can I access browser history in my iOS project?
Or, maybe, is there a way to track if the phone has made a request from a certain IP?
I just want to create a condition to see if a user has visited my website.
No.
Due to the application sandbox for third party apps, you cannot track/access previous network requests outside your app.
Learn more about app sandboxing here.
The only way I can think of doing this is to get current IP of the user:
Swift - Get device's IP Address
Then do a get request to see if it is in my server logs. But this is not very reliable as they may have visited the website on a different network.
Could request a location one the phone and on the browser then compare lat and long to see if in a radius... still, not a reliable solution.

What happens when you try to log into Facebook from behind China's great firewall?

For a few clients now, I've had a request to hide the "login with Facebook" feature in China, where Facebook is blocked. There are a couple ways I can think of to do this:
1) Use device locale.
Advantage: super simple!
Disadvantage: Inaccurate— someone in China could have their device set to en_US, and someone in the US could have their phone set to zh_CN. No dice.
2) Use GPS and reverse geocoding.
Advantage: You are actually measuring if the person is currently in the territory you've marked as 'restricted'.
Disadvantage: Requires the user to give you location permissions. Unclear what to do as a fallback if the user declines permissions. Some apps don't use GPS for anything else, and adding it just for this would be overkill.
3) Use a reachability check to http://facebook.com.
Advantage: You're going beyond checking whether the user is in an arbitrary location and actually checking to see whether facebook is currently restricted. If China stops blocking Facebook, your app starts supporting it immediately.
Disadvantage: You end up hiding the login UI if you're offline (which might not be a huge problem, because Facebook login won't work offline no matter where in the world you are).
Big unknown: What happens in China when you try to log into Facebook? Does it return a 404? Redirect to another site? Google searches around this (as linked above) just return things along the lines of "how to get around the Great Firewall" rather than "here's what actually happens when it's blocked".
So, the question: What happens when you try to log into Facebook from behind China's great firewall?
Trying to access Facebook in mainland China would result in error, like 403 Forbidden or 404 Not Found.
GPS Might not be a good idea, because the GPS signal in China is drifted, and as a result many cities located on the boundary would get overlapped GPS position, including southern Shenzhen/northern Hong Kong, Zhuhai/Macau, NE China/Russia and such.
How about reading the Mobile Country Code? So that users who are using Chinese sim card in their iphone can be identified and the option for facebook login can be disabled. But this trick would not be useful on iPod/iPad. It would also affect Chinese users roaming outside their country. How about checking if the IP address belong to a Chinese ISP?

Is it possible to send Twitter auto-reply without GPS tracking?

I want to send an auto reply to the user's tweets from his iOS application, I am able to do that if the user has allowed the iOS application to access his location, but when the access to location is denied by the user, tweeter is not allowing sending the auto reply to tweets.
I'm wondering whether it is mandatory to have access to the user's location to send an auto reply to his tweets. Or, do we have some reliable way to accomplish the specified functionality without accessing user's location?
OP, from what I understood, you want to find out a given user's location without consented access to the user's phone's location services.
A way to do this, not super reliable I'd add, is to reverse geolocate their IP Address using a server side geocode API.
Mind you, it is not super reliable but might do the trick. You might encounter problems on mobiles, especially due to the erratic nature of their IP Addresses.
Twitter themselves have an API to help on that. For example you could use GET geo/search to find out a place ID closest to a given IP Address using this:
https://dev.twitter.com/rest/reference/get/geo/search
and then you could use that place ID to find out the approximate Lat / Long of the user, using GET geo/id/:place_id:
https://dev.twitter.com/rest/reference/get/geo/id/%3Aplace_id
(there are probably straighter ways of doing this in other APIs aswell but I'm assuming you are already authenticated on twitter's API so I'm trying to give you something easier to integrate into your code)
Let me know if that helps.
I haven't implemented it yet but can guess that Twitter does so to avoid the spam or robotics tweets. So if Twitter gets multiple auto Tweets from same place so he would consider them as spam.
What you can do is after every 8-10 Tweets make new latitude longitude and send this location to Twitter while using auto tweeting.
How ?
Take a default location (lat, long) and you can find add 500m-1km in that location every 8-10 Tweets and use this new location for next time. This method is not reliable but can work in your case.
Note: Use this way only in case when you're not able to get device location.

Detect if W3 Geolocation has already been allowed

I have a Google Map on my site and am using W3 Geolocation to detect a users location when they click a button, "Get current location". Then it should popup with the allow/deny infobar at the top of the browser window.
I don't want to prompt all my visitors for Geolocation access but do want to somehow remember if a user has already allowed the Geolocation and run Geolocation if so.
From my research this isn't possible but I'm hoping someone has ran into this situation before. The only way I can figure this can be done is setting a cookie.
Thanks!
This is not exactly what you want, but I think it can be helpful.
According to W3C draft you can try to get any cached value from browser (without user's confirmation) or fallback to custom method, if no cached value found.
Assuming user has agreed to provide geolocation, it will be cached. Example from the same W3C draft:
// Request a position. We only accept cached positions, no matter what
// their age is. If the user agent does not have a cached position at
// all, it will immediately invoke the error callback.
navigator.geolocation.getCurrentPosition(successCallback,
errorCallback,
{maximumAge:Infinity, timeout:0});

Resources