how to open native calendar from titanium app for android and iOS? As in, on the click of a button, i want to open the native calendar on the ipad.
Asked
Active
Viewed 1,909 times
1
-
And why? What do you want to do? Simply open the app? – mr.VVoo Apr 08 '13 at 12:20
-
yes, i have a button called 'View Appointments in Calendar'. on clicking that, the native calendar should open up – user2189878 Apr 08 '13 at 12:25
2 Answers
1
Just use:
Titanium.Platform.openURL('CALSHOW://');

Tamir Abutbul
- 7,301
- 7
- 25
- 53

Stef
- 33
- 5
-
This only works on iOS. See asanlo's answer for the android part of the answer. – minnow Nov 04 '14 at 02:30
1
In android you can open it using a native intent, as explained here
There's a difference between versions lower and greater than Gingerbread. There's also a difference in HTC devices because of the HTC Sense Software, as explained at the end of this question.
Here is my tested code for Titanium:
if (Titanium.Platform.osname=="android"){
//Params needed to create the android intent.
var packageStr = "com.google.android.calendar";
var classStr = "com.android.calendar.LaunchActivity";
var actionStr = Ti.Android.ACTION_VIEW;
var model = Ti.Platform.model;
if ((model.indexOf("HTC") != -1) || (model.indexOf("htc") != -1)){
//If it's a HTC device
packageStr = "com.htc.calendar";
classStr = "com.htc.calendar.MonthActivity";
actionStr = Ti.Android.ACTION_MAIN;
}
else {
//For android versions before Gingerbread (2.3)
var version = parseFloat(Ti.Platform.version);
if (version < 2.4) packageStr = "com.android.calendar";
}
//Launch native calendar
var intent = Ti.Android.createIntent({
action: actionStr,
packageName: packageStr,
className: classStr
});
Ti.Android.currentActivity.startActivity(intent);
}
You can also open the "create event" screen of the native calendar by adapting this for Titanium in the same way as the code above