void PostNotification()
        {
            DirectoryInfo info = Tizen.Applications.Application.Current.DirectoryInfo;
            string        iconPath;
            string        bgPath;
            string        sharedPath         = info.SharedResource;
            string        customViewNotiBody =
                "{"
                + "\"template\": \"standard\","
                + "\"manifest_version\": 1,"
                + "\"model_info\": \"tizen_public\","
                + "\"category\": 3,"
                + "\"paragraph\": [{"
                + "\"type\": \"image\","
                + "\"content\": \"\","
                + "\"thumbnail\": \"/opt/usr/globalapps/org.tizen.example.NotificaiontTest/shared/res/bg_square.jpg\""
                + "}, {"
                + "\"type\": \"text\","
                + "\"content\": \"<color=#62dd16ff font_size=70 font=Tizen:style=Bold>2000</color><br/><color=#62dd16ff font_size=28 font=Tizen:style=Regular>/2000 steps</color>\""
                + "}, {"
                + "\"type\": \"text\","
                + "\"content\": \"<color=#ffffffff font_size=30 font=Tizen:style=Regular>You've earned step rewards once this week!</color>\""
                + "}],"
                + "\"always_wear\": 1"
                + "}";

            iconPath = sharedPath + "NotificationTestServiceApp.png";
            bgPath   = sharedPath + "bg_square.jpg";

            Notification noti = new Notification
            {
                Title   = "COVID-19 TEST",
                Content = customViewNotiBody,
                Icon    = iconPath
            };

            Notification.AccessorySet accessory = new Notification.AccessorySet
            {
                SoundOption = AccessoryOption.On,
                CanVibrate  = true
            };

            noti.Accessory = accessory;

            Notification.ActiveStyle style = new Notification.ActiveStyle
            {
                IsAutoRemove    = true,
                BackgroundImage = bgPath
            };

            AppControl firstAppControl = new AppControl
            {
                ApplicationId = UiAppID
            };

            Notification.ButtonAction button1 = new Notification.ButtonAction
            {
                Index  = Tizen.Applications.Notifications.ButtonIndex.First,
                Text   = "Launch UI App",
                Action = firstAppControl
            };

            AppControl secondAppControl = new AppControl
            {
                ApplicationId = ServiceAppID
            };

            secondAppControl.ExtraData.Add("op", "stop");

            Notification.ButtonAction button2 = new Notification.ButtonAction
            {
                Index  = Tizen.Applications.Notifications.ButtonIndex.Second,
                Text   = "Stop Service Noti Loop",
                Action = secondAppControl
            };

            style.AddButtonAction(button1);
            style.AddButtonAction(button2);

            noti.AddStyle(style);
            Log.Info("VCApp", "[VC] Post service........");
            NotificationManager.Post(noti);
        }
Exemple #2
0
        public void CreateNotificationTemplate(String name, String bgImage, String title, bool isThreeButton)
        {
            DirectoryInfo info = Tizen.Applications.Application.Current.DirectoryInfo;
            String        iconPath;
            String        bgPath;
            String        sharedPath         = info.SharedResource;
            string        customViewNotiBody =
                "{"
                + "\"template\": \"standard\","
                + "\"manifest_version\": 1,"
                + "\"model_info\": \"tizen_public\","
                + "\"category\": 3,"
                + "\"paragraph\": [{"
                + "\"type\": \"image\","
                + "\"content\": \"\","
                + "\"thumbnail\": \"/opt/usr/globalapps/org.tizen.example.NotificaiontTest/shared/res/bg_square.jpg\""
                + "}, {"
                + "\"type\": \"text\","
                + "\"content\": \"<color=#62dd16ff font_size=70 font=Tizen:style=Bold>2000</color><br/><color=#62dd16ff font_size=28 font=Tizen:style=Regular>/2000 steps</color>\""
                + "}, {"
                + "\"type\": \"text\","
                + "\"content\": \"<color=#ffffffff font_size=30 font=Tizen:style=Regular>You've earned step rewards once this week!</color>\""
                + "}],"
                + "\"always_wear\": 1"
                + "}";

            iconPath = sharedPath + "NotificaiontTest.png";
            bgPath   = sharedPath + bgImage;

            Console.WriteLine($"ICON {bgPath}");
            Notification noti = new Notification
            {
                Title   = title,
                Content = customViewNotiBody, // "quick brown fox jumps over the lazy dog",
                Icon    = iconPath
            };

            Notification.AccessorySet accessory = new Notification.AccessorySet
            {
                SoundOption = AccessoryOption.On,
                CanVibrate  = true
            };

            noti.Accessory = accessory;

            Notification.ActiveStyle style = new Notification.ActiveStyle
            {
                IsAutoRemove    = true,
                BackgroundImage = bgPath
            };

            AppControl firstAppControl = new AppControl
            {
                ApplicationId = UiAppID
            };

            Notification.ButtonAction button1 = new Notification.ButtonAction
            {
                Index  = Tizen.Applications.Notifications.ButtonIndex.First,
                Text   = "Launch UI App",
                Action = firstAppControl
            };

            AppControl secondAppControl = new AppControl
            {
                ApplicationId = ServiceAppID
            };

            secondAppControl.ExtraData.Add("op", "stop");

            Notification.ButtonAction button2 = new Notification.ButtonAction
            {
                Index  = Tizen.Applications.Notifications.ButtonIndex.Second,
                Text   = "Stop Service Noti Loop",
                Action = secondAppControl
            };

            style.AddButtonAction(button1);
            style.AddButtonAction(button2);

            if (isThreeButton)
            {
                Notification.ButtonAction button3 = new Notification.ButtonAction
                {
                    Index = Tizen.Applications.Notifications.ButtonIndex.Third,
                    Text  = "Btn-3",
                };
                style.AddButtonAction(button3);
            }

            noti.AddStyle(style);

            NotificationManager.SaveTemplate(noti, name);
        }