ANDROID---create notification and click on notification lunch
//android var intent = Ti.Android.createIntent( { action : Ti.Android.ACTION_MAIN, className : Ti.App.id+'activity_name', // activity_name that save inside build\android\bin\classes folder in titanium project packageName : Ti.App.id }); intent.addCategory(Titanium.Android.CATEGORY_LAUNCHER); var pending = Ti.Android.createPendingIntent( { activity : Ti.Android.currentActivity, intent : intent, type : Ti.Android.PENDING_INTENT_FOR_ACTIVITY, flags : Ti.Android.FLAG_ACTIVITY_NO_HISTORY }); var dateValue = new Date(); var notification = Ti.Android .createNotification( { contentIntent : pending, contentTitle : '--Title of noticaification--', contentText : '----message would you want to show------', when : dateValue.getTime(), //show timing in notification icon : Ti.App.Android.R.drawable.appicon, flags : Titanium.Android.ACTION_DEFAULT | Titanium.Android.FLAG_AUTO_CANCEL | Titanium.Android.FLAG_SHOW_LIGHTS }); //Ti.Android.NotificationManager.notify(Math.floor(Math.random() * 32, 767), notification); Ti.Android.NotificationManager.notify(1, notification);IPHONE---create local notification and click on ok button relunch application
//iphone var notification = Ti.App.iOS.scheduleLocalNotification({ alertBody:'-----message would you want to show------', alertAction:"OK", sound:"default", userInfo:{},//pass value to other screen use this userInfo field date:new Date(new Date().getTime() + 3000)// 3 seconds after backgrounding });for recieve that data that would be pass though notication ..write this code
Ti.App.iOS.addEventListener('notification', function(d) { Ti.API.info('data received = ' + JSON.stringify(d)); });
No comments:
Post a Comment