语言

Menu
Sites
Language
Customize Notifications Wearable 2.3.2 Tizen Native

Hello Everyone, 

I´m new to Tizen, and I tried to develop a wearable native App(2.3.2) where notifications can be created by clicking on a button. So far it works, but I was wondering if the notifications could be customized. 

e.g. I couldn´t manage to insert a button for user interaction on the notifications. Is this possible?

Addituonally, is there a way to customize the popup which is (automatically?) shown everytime when a new notification is created? 

And is it possible to delete the timestamp shown under the notification title in the notification tray? I´m also not sure what time there is displayed at all, it seems completely random to me...? 

I tried it with DO_NOT_SHOW_TIMESTAMP and variations of notification_set_time, but neither seemed to influence the shown value of the notifications at all.

Below is a part of the code:

void set_notification(appdata_s *ad){
notification_h notification = NULL;
notification = notification_create(NOTIFICATION_TYPE_NOTI);
if(notification != NULL){
 
notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE, "Alarm",
NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
 
notification_set_time_to_text(notification, time(NULL), NOTIFICATION_TEXT_TYPE_CONTENT);
notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT, "Failure of Valve 4",
NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
notification_set_display_applist(notification, NOTIFICATION_DISPLAY_APP_ALL);
notification_set_size(notification, 0.5);
notification_set_layout(notification, NOTIFICATION_LY_ONGOING_EVENT );
//notification_add_button(notification,NOTIFICATION_BUTTON_1);
notification_set_vibration(notification, NOTIFICATION_VIBRATION_TYPE_DEFAULT, NULL);
}
app_control_h app_control = NULL;
int noti_err = NOTIFICATION_ERROR_NONE;
 
app_control_create(&app_control);
app_control_set_app_id(app_control, "org.tizen.noti_basicui2");
 
noti_err = notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL,
(void *) app_control);
if (noti_err != NOTIFICATION_ERROR_NONE) {
notification_free(notification);
return;
}
app_control_destroy(app_control);
notification_post(notification);
}

Thanks for your help & answers!

查看选择的答案

响应

2 回复
Mark as answer
Yasin Ali

Hi,

You used notification_add_button() that is available with Tizen 3.0 and Higher for Wearable.
See this link for details: https://developer.tizen.org/development/guides/native-application/notifications-and-content-sharing/notifications
Another way you may try with is Notification popup
Link:  https://developer.tizen.org/community/code-snippet/native-code-snippet/notification-popup?tab=all
Notification Window
Link:  https://developer.tizen.org/community/code-snippet/native-code-snippet/how-create-notification-window?tab=all
But using these same code for wearables may produce irrelevant behavior. So, you need to adapt these ideas within your code.

About Timestamp:

int notification_set_time  ( notification_h  noti,time_t  input_time )

sets a timestamp.
If input_time is 0, time information is taken from the current time.
You may use like this way:

int noti_err = NOTIFICATION_ERROR_NONE;
....
noti_err  = notification_set_time(noti, time(NULL));

Hope it'll help.

wally

Hi,

thank you very much for your help. I could solve the problem with the timestamp now, and I´ll have a closer look at the mentioned examples about the popup. Thank you,