Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28140] Android: WebView should request location permission when HTML uses geolocation API

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2020-11-25T15:26:15.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.3.0
ComponentsAndroid
LabelsWebView, android, geolocation, html, permission
ReporterJoshua Quick
AssigneeJoshua Quick
Created2020-09-16T04:32:58.000+0000
Updated2020-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();

Comments

  1. Joshua Quick 2020-09-19

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12105
  2. Sohail Saddique 2020-10-08

    FR passed for this part of the PR
  3. Samir Mohammed 2020-11-25

    *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

JSON Source