Beispiel #1
0
        private async void OnClickDefaultNotification(object sender, System.EventArgs e)
        {
            string Tag = "LocalNotification Default";

            try
            {
                var notification = new Bundle();
                FillCommonParts(notification);
                FillBundle(notification);
                await NotificationController.LocalNotificationNow(this, notification);

                log.Info(Tag, "Success");
            }
            catch (ApiException exception)
            {
                log.Error(Tag, "Error/Exception: " + exception);
            }
        }
Beispiel #2
0
        private async void OnClickVibrate(object sender, System.EventArgs e)
        {
            string Tag = "Vibrate";

            try
            {
                var notification = new Bundle();
                FillCommonParts(notification);
                FillBundle(notification);
                notification.PutBoolean(NotificationConstants.Vibrate, true);//Indicates whether to enable the vibration mode when a notification message is pushed.
                await NotificationController.LocalNotificationNow(this, notification);

                log.Info(Tag, "Success");
            }
            catch (ApiException exception)
            {
                log.Error(Tag, "Error/Exception: " + exception);
            }
        }
Beispiel #3
0
        public async void OnClickBigImage(object sender, System.EventArgs e)
        {
            string Tag = "BigImage";

            try
            {
                var notification = new Bundle();
                FillCommonParts(notification);
                FillBundle(notification);
                notification.PutString(NotificationConstants.BigPictureUrl, "https://www-file.huawei.com/-/media/corp/home/image/logo_400x200.png"); //URL of the large image for notification messages.
                await NotificationController.LocalNotificationNow(this, notification);

                log.Info(Tag, "Success");
            }
            catch (ApiException exception)
            {
                log.Error(Tag, "Error/Exception: " + exception);
            }
        }
Beispiel #4
0
        private async void OnClickSound(object sender, System.EventArgs e)
        {
            string Tag = "Sound";

            try
            {
                var notification = new Bundle();
                FillCommonParts(notification);
                FillBundle(notification);
                notification.PutBoolean(NotificationConstants.PlaySound, true);               //Indicates whether a sound is played when a notification message is pushed.
                notification.PutString(NotificationConstants.SoundName, "huawei_bounce.mp3"); //Name of the sound file to be played in the raw directory when a notification message is pushed.
                await NotificationController.LocalNotificationNow(this, notification);

                log.Info(Tag, "Success");
            }
            catch (ApiException exception)
            {
                log.Error(Tag, "Error/Exception: " + exception);
            }
        }
Beispiel #5
0
        private async void OnClickOnGoing(object sender, System.EventArgs e)
        {
            string Tag = "OnGoing";

            try
            {
                var notification = new Bundle();
                FillCommonParts(notification);
                FillBundle(notification);
                //Indicates whether a notification message to be pushed is an ongoing message.
                //This message cannot be canceled by users through swiping, but can be canceled by the app.
                notification.PutBoolean(NotificationConstants.Ongoing, true);
                await NotificationController.LocalNotificationNow(this, notification);

                log.Info(Tag, "Success");
            }
            catch (ApiException exception)
            {
                log.Error(Tag, "Error/Exception: " + exception);
            }
        }
Beispiel #6
0
        private async void OnClickRepeate(object sender, System.EventArgs e)
        {
            string Tag = "Repeate";

            try
            {
                var notification = new Bundle();
                FillCommonParts(notification);
                FillBundle(notification);
                //notification.PutString(NotificationConstants.RepeatType, Repeat.Type.Second);
                //or
                notification.PutString(NotificationConstants.RepeatType, Repeat.Type.CustomTime);  //Time when a scheduled notification message is pushed repeatedly.
                notification.PutLong(NotificationConstants.RepeatTime, 5 * Repeat.Time.OneSecond); //Time when the next scheduled notification message is pushed repeatedly, in milliseconds.

                await NotificationController.LocalNotificationNow(this, notification);

                log.Info(Tag, "Success");
            }
            catch (ApiException exception)
            {
                log.Error(Tag, "Error/Exception: " + exception);
            }
        }
 public async Task LocalNotificationNow(XamarinFormsPushDemo.HMSPush.Model.LocalNotification notification)
 {
     await NotificationController.LocalNotificationNow(Application.Context, NotificationToBundle(notification));
 }