[Tizen6.5 Migration][Service] Support simple notification popup 09/249009/2
authorDongHyun Song <dh81.song@samsung.com>
Wed, 6 Jan 2021 03:32:25 +0000 (12:32 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Wed, 6 Jan 2021 03:32:25 +0000 (12:32 +0900)
User apps can use this notification posting API by calling
webapis.postPlainNotification()
 - title: string, mandatory
 - message: string, mandatory
 - timeout: number, optional (10s default)

Actually, this feature is alternative simple solution to show
notification popup of tizen.UserNotification webapi.
Global notification webapis is not included in TV platform.

Related patch:
  https://review.tizen.org/gerrit/250942/

Change-Id: Ibf51f707be4b1edf3fc50dd94041df38cbdae168
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/service/device_api_router.ts

index 7cb70cb..7f6548f 100644 (file)
@@ -37,21 +37,30 @@ export class DeviceAPIRouter {
   }
 
   initWebapis() {
-    global.webapis = global.webapis ?? {};
+    let app_info = global.tizen.application.getAppInfo(this.serviceId);
+    if (app_info) {
+      this.packageId = app_info.packageId;
+    }
 
+    global.webapis = global.webapis ?? {};
     global.webapis.getCallerAppId = () => {
       return this.callerAppId;
     }
     global.webapis.getServiceId = () => {
       return this.serviceId;
     }
-    let app_info = global.tizen.application.getAppInfo(this.serviceId);
-    if (app_info) {
-      this.packageId = app_info.packageId;
-    }
     global.webapis.getPackageId = () => {
       return this.packageId;
     }
+    global.webapis.postPlainNotification = (title: string, message: string, timeout?: number) => {
+      return wrt.postPlainNotification(title, message, timeout ?? 10);
+    }
+    Object.defineProperties(global.webapis, {
+      getCallerAppId: { writable: false, enumerable: true },
+      getPackageId: { writable: false, enumerable: true },
+      getServiceId: { writable: false, enumerable: true },
+      postPlainNotification: { writable: false, enumerable: true },
+    });
     this.initProductWebapis();
   }