Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20003] Permission request error response message prefixed with namespace

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-11-23T03:06:58.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sRelease 5.1.2
ComponentsAndroid
Labelsn/a
ReporterFokke Zandbergen
AssigneeFokke Zandbergen
Created2015-11-17T13:34:54.000+0000
Updated2015-12-07T19:12:08.000+0000

Description

The following code demonstrates that when you deny permission, the error messages in the callback payload are prefixed by the _namespace_ followed by no spacing. Expected behaviour is not to have a prefix at all.
var win = Ti.UI.createWindow({
	backgroundColor: 'white'
});

var btn = Ti.UI.createButton({
	title: 'Request Permissions'
});

btn.addEventListener('click', function(e) {

	Ti.Calendar.requestCalendarPermissions(function(e) {
		console.log('Ti.Calendar.requestCalendarPermissions ' + JSON.stringify(e, null, 2));
	});

	Ti.Contacts.requestContactsPermissions(function(e) {
		console.log('Ti.Contacts.requestContactsPermissions ' + JSON.stringify(e, null, 2));
	});

	Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_ALWAYS, function(e) {
		console.log('Ti.Geolocation.requestLocationPermissions ' + JSON.stringify(e, null, 2));
	});

	Ti.Media.requestCameraPermissions(function(e) {
		console.log('Ti.Media.requestCameraPermissions ' + JSON.stringify(e, null, 2));
	});

});

win.add(btn);
win.open();

// So the required users-permissions are added to AndroidManifest.xml
function foo() {
	Ti.Calendar.getAllCalendars();
	Ti.Contacts.getAllGroups();
	Ti.Media.showCamera();
}
*Console*
11-17 14:11:46.421: I/TiAPI(5178):  Ti.Media.requestCameraPermissions {
11-17 14:11:46.421: I/TiAPI(5178):   "error": "CameraOne or more permission(s) were denied",
11-17 14:11:46.421: I/TiAPI(5178):   "code": -1,
11-17 14:11:46.421: I/TiAPI(5178):   "success": false
11-17 14:11:46.421: I/TiAPI(5178): }
11-17 14:11:46.422: I/TiAPI(5178):  Ti.Geolocation.requestLocationPermissions {
11-17 14:11:46.422: I/TiAPI(5178):   "error": "LocationOne or more permission(s) were denied",
11-17 14:11:46.422: I/TiAPI(5178):   "code": -1,
11-17 14:11:46.422: I/TiAPI(5178):   "success": false
11-17 14:11:46.422: I/TiAPI(5178): }
11-17 14:11:46.422: I/TiAPI(5178):  Ti.Contacts.requestContactsPermissions {
11-17 14:11:46.422: I/TiAPI(5178):   "error": "ContactsOne or more permission(s) were denied",
11-17 14:11:46.422: I/TiAPI(5178):   "code": -1,
11-17 14:11:46.422: I/TiAPI(5178):   "success": false
11-17 14:11:46.422: I/TiAPI(5178): }
11-17 14:11:46.422: I/TiAPI(5178):  Ti.Calendar.requestCalendarPermissions {
11-17 14:11:46.422: I/TiAPI(5178):   "error": "CalendarOne or more permission(s) were denied",
11-17 14:11:46.422: I/TiAPI(5178):   "code": -1,
11-17 14:11:46.422: I/TiAPI(5178):   "success": false
11-17 14:11:46.422: I/TiAPI(5178): }
Related code: https://github.com/appcelerator/titanium_mobile/blob/a0e6b6545594b64d95dc91a496e3242342de9db1/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java#L440

Comments

  1. Fokke Zandbergen 2015-11-17

    PR: https://github.com/appcelerator/titanium_mobile/pull/7458
  2. Hans Knöchel 2015-11-20

    Approved! But if we want this in 5.1.1, we need a 5_1_X backport by time. Will wait to resolve until that decision is cleared. /cc [~cng]
  3. Chee Kiat Ng 2015-11-20

    yes we need that back port. Then once we merge next week for 5.1.1, we will resolve this ticket.
  4. Fokke Zandbergen 2015-11-20

    PR for 5_1_X: https://github.com/appcelerator/titanium_mobile/pull/7478
  5. Hans Knöchel 2015-11-23

    Backport approved!
  6. Eric Wieber 2015-11-23

    Verified fixed, using: MacOS 10.11.2 (15C47a) Studio 4.4.0.201511182122 Ti SDK 5.1.1.v20151122191220 Appc NPM 4.2.2 Appc CLI 5.1.0 Ti CLI 5.0.5 Alloy 1.7.26 Arrow 1.3.22 Xcode 7.1 (7B91b) Node v0.12.7 Java 1.7.0_80 production The error response for denied permissions is not prefixed with the namespace. Used the test code provided and denied permissions via the prompt as well as not defining them in the tiapp.
  7. Chee Kiat Ng 2015-11-26

    To Note: This ticket is marked 5.1.2 but PR was merged in 5.1.1GA
  8. Lokesh Choudhary 2015-12-07

    Verified the fix with SDK 5.1.2.v20151206185250 as well

JSON Source