Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created December 5, 2012 15:22
Show Gist options
  • Save alanleard/4216486 to your computer and use it in GitHub Desktop.
Save alanleard/4216486 to your computer and use it in GitHub Desktop.
Android Local Notification
var intent = Ti.Android.createServiceIntent({url: 'notification.js'});
Ti.Android.stopService(intent);
////*notification.js*////////
Titanium.Android.NotificationManager.notify(
0, // <-- this is an ID that we can use to clear the notification later
Ti.Android.createNotification({
//contentView: customView,
contentTitle: "Local Notification",
icon:0x7f020000,
contentText: "Notification Message",
// when: now,
tickerText: "This is my ticker message",
contentIntent: Ti.Android.createPendingIntent({
intent: Ti.Android.createIntent({
url: 'app.js'
})
})
}));
var intent = Ti.Android.createServiceIntent({
url: 'notification.js'
});
Ti.Android.stopService(intent);
intent.putExtra('interval', 24*20*60*1000);
Ti.Android.startService(intent);
Ti.App.Properties.setInt('notificationCount', 2);
} else if(Ti.App.Properties.getInt('notificationCount')==2){
Titanium.Android.NotificationManager.notify(
0, // <-- this is an ID that we can use to clear the notification later
Ti.Android.createNotification({
//contentView: customView,
contentTitle: "Local Notification",
icon:0x7f020000,
contentText: "Notification Message",
// when: now,
tickerText: "This is my ticker message",
contentIntent: Ti.Android.createPendingIntent({
intent: Ti.Android.createIntent({
url: 'app.js'
})
})
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment