Home Ask Login Register

Developers Planet

Your answer is one click away!

Asif February 2016

Time based notifications

I am building an app which needs to send time-based notifications to the user.

I am using Notification Manager module and background services and pushing the notifications. This is working fine as long as the app is opened either in background or accessible.

Once I close the app, then notifications are not coming. How can I ensure that my service is running even though my app is closed and keep sending notifications?


cuppaBunny February 2016

Start your service using Titanium.Android.startService For Example,


var intent = Titanium.Android.createServiceIntent({
    url: 'myservice.js'
intent.putExtra('interval', 10000); // Service should run its code every 2 seconds.
intent.putExtra(Titanium.Android.EXTRA_DONT_KILL_APP, true);


var intent = Ti.Android.createIntent({
   action: Ti.Android.ACTION_MAIN,
   className: 'com.testApp.TestappActivity',
   packageName: 'com.testApp'


var pending = Titanium.Android.createPendingIntent({
   intent: intent,
   flags: Titanium.Android.FLAG_UPDATE_CURRENT

var notification = Titanium.Android.createNotification({
   contentTitle: 'Something Happened',
   contentText: 'Click to return to the application.',
   contentIntent: pending

Titanium.Android.NotificationManager.notify(1, notification);

Also add service to your tiapp.xml,

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <service url="myservice.js" type="interval" />

Post Status

Asked in February 2016
Viewed 1,123 times
Voted 11
Answered 1 times


Leave an answer

Quote of the day: live life