[TIMOB-28140] Android: WebView should request location permission when HTML uses geolocation API
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2020-11-25T15:26:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 9.3.0 |
Components | Android |
Labels | WebView, android, geolocation, html, permission |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2020-09-16T04:32:58.000+0000 |
Updated | 2020-11-25T15:26:15.000+0000 |
Description
*Summary:*
When a WebView HTML's JavaScript uses the [Geolocation](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API) web API, it should automatically prompt the end-user for permission on Android 6.0 and above.
Currently, permission will always be denied unless you call the [Ti.Geolocation.requestLocationPermissions()](https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-requestLocationPermissions) method yourself before loading the webpage.
*Test Case:*
Create a Classic Titanium app project.
Add the below Android permission to the "tiapp.xml".
Use the below "app.js" code.
Build and run on Android 6.0 or higher.
Tap on the "Your Location" button in the map.
Verify a dialog appears asking you for permission. _(This is the feature we're adding.)_
Grant permission.
Verify map shows your current location.
tiapp.xml
<ti:app>
<android>
<manifest>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>
</android>
</ti:app>
app.js
var window = Ti.UI.createWindow();
window.add(Ti.UI.createWebView({
url: 'https://maps.google.com',
borderRadius: 1,
}));
window.open();
PR (master): https://github.com/appcelerator/titanium_mobile/pull/12105
FR passed for this part of the PR
*Closing ticket*. Fix verified in SDK version
9.3.0.v20201125050632
. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/12105