How to Create Local Notification On Android?

You must Login before you can answer or comment on any questions.

I want to create a local notification when the user clicks the button.

I was working on the below code but couldn't figure the problem?

Notificationbutton.addEventListener('click',function(){
    var AppIntent = Ti.Android.createIntent({
        flags : Titanium.Android.FLAG_ACTIVITY_CLEAR_TOP
                    className : 'ti.modules.titanium.ui.TiTabActivity',
                    packageName : Ti.App.id
                });
                AppIntent.addCategory(Ti.Android.CATEGORY_LAUNCHER);
 
                var NotificationClickAction = Ti.Android.createPendingIntent({
                    activity : Ti.Android.currentActivity,
                    intent : AppIntent,
                    flags : Ti.Android.FLAG_UPDATE_CURRENT,
                    type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY
                });
 
                var NotificationMembers = {
                    contentTitle : 'St. Elizabeth Healthcare',
                    contentText : 'Select to return to Run Tracker',
                    tickerText : "Run Tracker started...",
                    when : new Date().getTime(),
                    flags : (Ti.Android.FLAG_ONGOING_EVENT | Ti.Android.FLAG_NO_CLEAR),
                    contentIntent : NotificationClickAction
                };
 
     Ti.Android.NotificationManager.notify(1, Ti.Android.createNotification(NotificationMembers));
});
I am using the Titanium version 2.0.2 in Android API level 2.3.3

Your Answer

Think you can help? Login to answer this question!