语言

Menu
Sites
Language
Recurring notifications

Hi everyone,

I'm trying to show notifications at specific times. (Like an AlarmRelative or AlarmAbsolute, but then a notification)
With an AlarmRelative I'd do the following:
var alarm = new tizen.AlarmRelative(tizen.alarm.PERIOD_HOUR, tizen.alarm.PERIOD_HOUR);
tizen.alarm.add(alarm, tizen.application.getCurrentApplication().appInfo.id);
This would set an alarm in an hour, every hour.
I would like to do this, but with a notification, so that it shows a notification e.g. every hour.
Is this possible? And if so, how?

I tried using the Calendar API, setting a repeating calendar item, but that didn't work out, as you can't create a hidden calendar item and the user must give permission for using the Calendar.

Any help would be greatly appreciated!

 

编辑者为: Brock Boland 17 3月, 2014 原因: Paragraph tags added automatically from tizen_format_fix module.

响应

4 回复
konduri sai swathi
Hi, Use setInterval() to post notification recursively only when the application is running.
setInterval(function(){post_notification();},5000);
function post_notification(){
	var notificationDict = {
			content : "This is a simple notification",
			iconPath : "image2.jpg",
			vibration : true,
	};
	var notification = new tizen.StatusNotification("SIMPLE", 
			"Simple notification", notificationDict);
	tizen.notification.post(notification);
}
Tiana Sweeney
Thanks for your reply! The problem with that is, as you said yourself, that it only works as long as you're application is running. I need it to be running at all times.
konduri sai swathi
Hi Tiana, I guess there is no other alternative. Or else if you want the notification to trigger even if the the application is not running, then create an alarm to first launch the application after a specified time and then the notification will be posted recursively with setInterval().
Tiana Sweeney
Ok, thanks. If that is the only option, the notification is not necessary anymore. I will just immediately send the user to the page, instead of notifying them that hey should go to that page. Showing a notification on a specific time is not possible either then I suppose?