قالب وردپرس درنا توس
Home / IOS Development / javascript – JS's current location does not work in iOS

javascript – JS's current location does not work in iOS



iOS and macOS do not give you the user's location if they do not allow or if the system cannot trust you. then:

– First (Probably your answer)

It works with the exact code you entered ONLY if the host uses https . This is why the permission alert does not appear because of your comment during a response.

Remember that if you do not use https it will get stuck for about a minute and then return an authentication failure error. Use error to check that:

  navigator.geolocation.getCurrentPosition (success, failure, options)

̵
1; Second:

If you use https you can check that the Safari setting is set to OFF in some way, you can change it here: Settings> Privacy> Location Services> Safari. This is not the default option, but maybe one day you accidentally changed it. So don't worry about the users if this was the problem.

– Third:

To load your web into an app using webView make sure to add permission permissions descriptions to the info.plist file. Add NSLocationWhenInUseUsageDescription versus NSLocationAlwaysUsageDescription versus NSLocationUsageDescription as your needs.

For completeness, in iOS13, you can't get [19459] permission. But this is not the point here, and the point is that you must get the necessary permissions once before you need to get the location from GPS, or it does not work at all.


Source link