Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3487] Calendar permissions in Titanium SDK for Android 6.0.0 and above.

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2016-04-18T06:16:56.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsCalendars, SDK, Titanium, android
ReporterMuhammad Sabir
AssigneeShak Hossain
Created2016-04-11T15:24:47.000+0000
Updated2016-04-19T12:32:32.000+0000

Description

Hi, I'm trying to add events and then reminder to that events by using a native module. In Android 6.0.0 and above, application has to ask user for a permission if application is using native calendars. I'm specifying the permission in tiapp.xml and by a method "requestCalendarPermissions". My application is working perfect for the previous versions of Android but crashing on Android 6.0.0 and above. I think Titanium SDK (currently using 5.2.0) does not has this permission to work with Calendars for Android 6.0.0. Please fix this issue or suggest me some work around so that I can complete my app. I would be grateful.

Comments

  1. Nazmus Salahin 2016-04-12

    Hello, Thanks for reporting. Actually Titanium SDK (5.2.0.GA) does have the functionality to work with Calendar Permission for Android 6. Also it is recommended to update SDK to latest stable version (5.2.2.GA). Here is a simple example to try. *Add permissions in tiapp.xml:*
          <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>           
                	 <uses-permission android:name="android.permission.READ_CALENDAR" />
              		 <uses-permission android:name="android.permission.WRITE_CALENDAR" />          
               </manifest>
           </android>
       
    *app.js*
       
       Titanium.UI.setBackgroundColor('#000');
       
       var win = Titanium.UI.createWindow({
       	title : 'Tab 1',
       	backgroundColor : '#fff'
       });
       
       win.open();
       
       function calenderTask() {
       	if (Ti.Calendar.hasCalendarPermissions()) {
       		showCalendars(Ti.Calendar.selectableCalendars);
       	} else {
       		Ti.Calendar.requestCalendarPermissions(function(e) {
       			if (e.success) {
       				showCalendars(Ti.Calendar.selectableCalendars);
       			} else {
       				Ti.API.error(e.error);
       				alert('Access to calendar is not allowed');
       			}
       		});
       	}
       }
       
       function showCalendars(calendars) {
       	for (var i = 0; i < calendars.length; i++) {
       		Ti.API.info("Calender: "+calendars[i].name);
       	}
       }
       
       calenderTask();
       
       
       
    Building and runnig the app on Android 6 show produce console log similar to the following.
       [INFO] :   Calender: Birthdays
       [INFO] :   Calender: Holidays 
       
    Thanks *Environment*: *Device info:* Nexux7 (android 6.0.1) *Node.js Version:* 0.12.7 *npm Version:* 2.11.3 *Titanium SDKs:* 5.2.2.GA and 5.2.1.GA *Java Development Kit Version:* 1.8.0_73 *Titanium CLI Version:* 5.0.5 *Appcelerator CLI Version:* 5.2.2 *Appcelerator Studio:* 4.4.0.201511241829
  2. Muhammad Sabir 2016-04-19

    Hi again, Actually I'm using a third party module as I want to create recurrent reminders and sometimes I've to delete them within the applications. When I create events without using this module my app works fine but when I use my module it is not working. I'm explicitly asking for calendar permissions from user as well. You can find my test case here, https://www.dropbox.com/s/r8h14gsx5nrss45/Test%20App.zip?dl=0

JSON Source