From: Myungki Lee Date: Fri, 8 Sep 2017 08:19:07 +0000 (+0900) Subject: [Notification] Add 4.0 new api guide X-Git-Tag: GitHub/PR#40/tizen-studio~25 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32eff717d40c94456ac08ff0c6b321bf47cfc0f6;p=sdk%2Fonline-doc.git [Notification] Add 4.0 new api guide PS4: Reviewed again. PS5: Added two typo fixes missed from PS4. Change-Id: I90647a57570f198167e009b4f7bebaf17799a7a8 Signed-off-by: Myungki Lee --- diff --git a/org.tizen.guides/html/native/notification/noti_n.htm b/org.tizen.guides/html/native/notification/noti_n.htm index 23fdb14..aa33e47 100644 --- a/org.tizen.guides/html/native/notification/noti_n.htm +++ b/org.tizen.guides/html/native/notification/noti_n.htm @@ -45,6 +45,7 @@
  • Displaying the Progress Bar
  • Creating an Active Notification with Text Input
  • +
  • Creating an Extended Notification
  • Using a Notification Template
  • Related Info

    @@ -137,7 +138,9 @@
  • NOTIFICATION_LY_NOTI_THUMBNAIL

    Layout for a notification displaying images.

  • NOTIFICATION_LY_ONGOING_PROGRESS -

    Layout for an ongoing notification displaying progress.

  • +

    Layout for an ongoing notification displaying progress.

    +
  • NOTIFICATION_LY_EXTENSION +

    Layout for an extended notification.

  • Figure: Notification layouts

    Notification layouts

    @@ -575,11 +578,110 @@ if (ret != APP_CONTROL_ERROR_NONE)

    Figure: Text input box

    Text input box

    +

    Creating an Extended Notification

    + +

    The extended notification layout is used to display long text or large images on the quick panel:

    + + +

    To show a large image, use the NOTIFICATION_IMAGE_TYPE_EXTENSION image type, and define the size of the image.

    + +

    To create an extended notification:

    + +
      +
    1. Create a notification and set the extended layout: +
      +notification_h noti_handle = NULL;
      +app_control_h app_control = NULL;
      +
      +/* Create a new notification */
      +noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
      +if (noti == NULL)
      +    /* Error handling */
      +
      +/* Set layout */
      +int ret = notification_set_layout(noti_handle, NOTIFICATION_LY_EXTENSION);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +
    2. +
    3. Set the notification attributes. For example, you can set the title text, the body text for basic and extended form, and the large image and its size: +
      +ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "Title",
      +                            NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +/* Body text for basic form */
      +ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "Body",
      +                            NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +/* Body text for extended form */
      +ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT_EXTENSION,
      +                            "Long Body", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +/* Large image */
      +ret = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_EXTENSION, image_path);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +/* Image height */
      +ret = notification_set_extension_image_size(noti_handle, 300);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +ret = notification_set_display_applist(noti_handle,
      +                                       NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +
    4. +
    5. Set the application control to launch an application when the user clicks the notification: +
      +ret = app_control_create(&app_control);
      +if (ret != APP_CONTROL_ERROR_NONE)
      +    /* Error handling */
      +
      +ret = app_control_set_app_id(app_control, appid);
      +/*
      +   Or use:
      +   ret = app_control_set_uri(app_control, uri);
      +*/
      +if (ret != APP_CONTROL_ERROR_NONE)
      +    /* Error handling */
      +
      +ret = notification_set_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL,
      +                                     app_control);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +
    6. +
    7. Post the notification: +
      +ret  = notification_post(noti_handle);
      +if (ret != NOTIFICATION_ERROR_NONE)
      +    /* Error handling */
      +
      +app_control_destroy(app_control);
      +
      +notification_free(noti_handle);
      +
      +
    +

    Using a Notification Template

    -

    To create a template from an existing notification, and reuse that template in another notification:

    +

    To create a template from an existing notification, and reuse that template later to quickly create other notifications with the same pattern:

    -
    1. Create a notification as usual.

      +
        +
      • To create a template: +
          +
        1. Create a notification as usual.

          The following example creates an active notification with 2 buttons (accept and cancel), a background image, sound, led, and vibration:

          @@ -685,19 +787,19 @@ ret = app_control_destroy(app_control);
           if (ret != APP_CONTROL_ERROR_NONE)
               /* Error handling */
           
        2. -
        3. To save the notification handle as a template and define a name for the template, use the notification_save_as_template() function:

          +
        4. Save the notification handle as a template and define a name for the template, using the notification_save_as_template() function:

           ret = notification_save_as_template(notification, "CALL_ACCEPT");
           if (ret != APP_CONTROL_ERROR_NONE)
               /* Error handling */
          -
        5. +
      • To use the template when creating a new notification, call the notification_create_from_template() function:

         notification_h notification = NULL;
         notification = notification_create_from_template("CALL_ACCEPT")
         if (noti == NULL)
             /* Error handling */
        -
    +