Created
August 28, 2015 17:39
-
-
Save egomez99/49b799b90b7cfc49c76d to your computer and use it in GitHub Desktop.
Android Notification Icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Titanium.UI.setBackgroundColor('#000'); | |
var win1 = Titanium.UI.createWindow({ | |
navBarHidden : true | |
}); | |
showAndroidNotification("Notification","App icon"); | |
win1.open(); | |
function showAndroidNotification(title, text) { | |
var AppIntent = Ti.Android.createIntent({ | |
flags : Titanium.Android.FLAG_ACTIVITY_CLEAR_TOP | Titanium.Android.FLAG_ACTIVITY_SINGLE_TOP, | |
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 : title, | |
contentText : text, | |
icon : Ti.App.Android.R.drawable.appicon, | |
when : new Date().getTime(), | |
defaults:Titanium.Android.NotificationManager.DEFAULT_SOUND, | |
flags : (Ti.Android.FLAG_ACTIVITY_CLEAR_TOP | Ti.Android.FLAG_AUTO_CANCEL), | |
contentIntent : NotificationClickAction | |
}; | |
Ti.Android.NotificationManager.notify(1, Ti.Android.createNotification(NotificationMembers)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment