Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
  Titanium Android Messaging Module

Countly is an innovative, real-time, open source mobile analytics application. It collects data from mobile phones, and visualizes this information to analyze mobile application usage and end-user behavior. There are two parts of Countly: the server that collects and analyzes data, and mobile SDK that sends this data (for iOS & Android).


Countly Server;

Titanium Countly Messaging Modules

Other Countly SDK repositories;

Countly SDK Guides;

This Titanium Android module is written to take use of all the functions - including events, userData, Messaging and now Crash Reports!

It is written with functions as close to the Android module as possible to create uniformed functions.

Please note that this Module is under development.

Please log issues via github issues

Any pull requests and suggestions welcome!

Author: Dieskim of (](

Development Sponsors:

- Messaging: - Friend who loves your way of working - Thanks!

- Crash Reports:

TEST APP - easy Test app you can download, build and run to test all the functions in this modul Countly Appcelerator Module Test App


  1. Go to:
  2. Download:
  3. Move Zip to root of your Application
  4. Build Application - Titanium will automatically extract the module

Register your module with your application by editing tiapp.xml and adding your module.

<module platform="android"></module>


Require the Module

var Countly = require('');

** Set App Name in AndroidManifest.xml

[WARN] :   ResourceType: No package identifier when getting value for resource number 0x00000000

[ERROR] :  MessagingAdapter: Couldn't store configuration in Countly Messaging

Enable Debugginh*

// enableDebug if needed

SETUP WITHOUT Messaging - Push

Start on own server without Messaging


Start on cloud without Messaging


SETUP WITH Messaging - Push

Set Push Setup functions


// *** IN ANDROID THERE IS NO NEED TO RUN recordPushOpen as it happens Automaticall on the Native Module side **//

// Raw pushMessage"Received Push");;  

var pushID =;
var pushAlertMessage = pushMessageData.message;
var pushType = pushMessageData.type || 'unknownType';
var pushLink = || '';
var pushSound = pushMessageData.sound || '';
var pushData =;						// all message data if needed"pushID: " + pushID + " pushAlertMessage: " + pushAlertMessage + "pushType: " + pushType + " pushData: " + pushData + " pushSound: " + pushSound);

if (pushType == "hasLink"){

//              SHOW AN LINK ALERT HERE                 //
// 1. Use info  - pushType
//              - pushLink
//              - pushAlertMessage
// 2. Once user Takes action log action with recordPushAction using pushID

// record Push Action  
// Countly.recordPushAction(pushID);    

}else if (pushType == "hasReview"){


}else if (pushType == "hasMessage"){




START Countly with Messaging - DEVELOPMENT TEST

// START Countly with Messaging - DEVELOPMENT TEST

START Countly with Messaging - PRODUCTION

// START Countly with Messaging - PRODUCTION

User Locations

// Countly Set user location
var latitudeString = 12;
var longitudeString = 10;
  • Takes two strings: latitudeString and longitudeString of 2 digit lengths


Set any of the following Fields in an Object

var segmentation = {device:"iPhone 4S", country:"USA"};
var eventData = {name: "keySegmentationCountSum", segmentation:segmentation, count: 1, sum: 0.99};
  • name (required) : Name of the event to track
  • (example - Track clicks on the help button "clickedHelp" )
  • count (required) : Number to increment the event in the db
  • (example - User purchases item increment by 1 )
  • sum : If the event is tied to an overall numerical data, such as a purchase, we can use sum to keep track of that
  • (example - 0.99)
  • segmentation : Categorization of the event
  • (example - User is from USA and uses an iPhone 4S so the segmentation will be {device:"iPhone 4S", country:"USA"} )

Track Events Examples

var segmentation = {device:"iPhone 4S", country:"USA"};

Ti.API.log("Send keyCount Event");
var eventData = {name: "keyCount", count: 1};

Ti.API.log("Send keyCountSum Event");
var eventData = {name: "keyCountSum", count: 1, sum: 0.99};

Ti.API.log("Send keySegmentationCount Event");
var eventData = {name: "keySegmentationCount", segmentation:segmentation, count: 1};

Ti.API.log("Send keySegmentationCountSum Event");
var eventData = {name: "keySegmentationCountSum", segmentation:segmentation, count: 1, sum: 0.99};


Set any of the following Fields in an Object

**Set userData{} as information about user **Possible keys are:

  • name - (String) providing user's full name
  • username - (String) providing user's nickname
  • email - (String) providing user's email address
  • organization - (String) providing user's organization's name where user works
  • phone - (String) providing user's phone number
  • picture - (String) providing WWW URL to user's avatar or profile picture
  • picturePath - (String) providing local path to user's avatar or profile picture
  • gender - (String) providing user's gender as M for male and F for female
  • byear - (int) providing user's year of birth as integer
var userData = {	name: "testName",
username: "testUsername",
email: "",
organization: "testOrg",
phone: "testPhone",
picture: "",
picturePath: "/images/appicon.png",
gender: "M",
byear: "1980",

**Set customUserData{} as information about user with custom properties **In customUserData you can provide any string key values to be stored with user

var customUserData = {	key1: "value1",

**Set Userdata as set in userData and customData **Can contain both userData and customData - or just userdata

Ti.API.log("Set UserData");
var args = {	userData:userData,


Crash Reporting

** There are 3 types of Crashes that can be logged:

  • Fatal Native Exception/Crash - Automatically logged via SDK
  • Fatal Javascript Exception/Crash - Automatically logged via Module after one function added (Titanium SDK > 4.1 only)
  • Non-Fatal Javascript Exception/Crash - Manually Logged by user in App code as needed via- Countly.recordHandledException
  • The user can also add entries to Crash logs in app code via - Countly.addCrashLog
  • 4 CrashTest are built in to help test crash reporting

Start Crash Reporting - WITH or WITHOUT Segments

  • Segments can be added as key values - these are sent with every crash
  • When Crash Reporting is started the Countly SDK will automatically catch and log Fatal Native Exception/Crash
// Start Crash Reporting - WITHOUT Segments
// Start Crash Reporting - WITH Segments
// Add Keypairs to be added to every Crash that is logged for this app
// Example: FacebookSDK: "4.0"
var segments = { 	FacebookSDK: "4.0",
key2: "value2",


Add Fatal Javascript Exception/Crash Support

  • Automatically logged via Module after one function added (Titanium SDK > 4.1 only)
  • This crash type will NOT QUIT out of app in Development (shows red error box), but will QUIT out of app in Production.
  • Error will be logged on Javascript side and sent to native module to send to Countly
  • For this to work you for need to add the uncaughtException listener to the app
  • Then run the Countly.recordUncaughtException inside the
Ti.App.addEventListener('uncaughtException', function(exception) {

Ti.API.log("Javascript Fatal Exception");   // remove if you want

// send exception to Countly


Add Non-Fatal Javascript Exception/Crash Support

  • This is a Crash Report you can Define and send Manually very much like an error log
  • run the Countly.recordHandledException function to manually log a non-fatal crash report
// Non-Fatal Javascript Exception/Crash Manually via  to Countly

Add Crash Log Entry

  • add Keypairs to a crash log as needed throughout your app
  • will be sent with crash log when/if app crashes
  • Example: Button Clicked, Audio Downloaded etc

var crashLog = {    yourMessage: "Error Message",
key1: "value1",


Crash Test

  • There are 4 types of Crash Test Built in
  • crashTest 3 will cause a native error and exit out of app - On Android Create a button to Run the Function and run it a few times quickly to make it exit the app
\\ NATIVE CRASH TESTS - Exits out of app and logs to Countly

\\ Other Crash Tests - Do not exit out of app - get logged via Ti.App.addEventListener uncaughtException

Get Countly Devide ID Used

// Countly getOUDID
var countlyDeviceID = Countly.getOUDID();
Ti.API.log("countlyDeviceID: " + countlyDeviceID);


Author: Dieskim of (](


MIT as in License.txt