Пример #1
0
        public void PostNotification()
        {
            Console.WriteLine("PostNotification");

            DirectoryInfo info = Tizen.Applications.Application.Current.DirectoryInfo;
            String        imagePath;
            String        sharedPath = info.SharedResource;

            imagePath = sharedPath + "NotificaiontTest.png";

            Notification notification = new Notification
            {
                Title   = "Notification TEST",
                Content = "Hello Tizen",
                Icon    = imagePath
            };

            Notification.AccessorySet accessory = new Notification.AccessorySet
            {
                SoundOption       = AccessoryOption.Custom,
                SoundPath         = "Sound File Path",
                CanVibrate        = true,
                LedOption         = AccessoryOption.Custom,
                LedOnMillisecond  = 100,
                LedOffMillisecond = 50,
                LedColor          = Tizen.Common.Color.Lime
            };

            notification.Accessory = accessory;

            NotificationManager.Post(notification);
        }
        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);
        }
Пример #3
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);
        }