Exemple #1
0
 private void DataSetWS_GetPeriodicDataCompleted(object sender, MobileAppPozitiv.GetPeriodicDataCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.Cancelled)
         {
         }
         else
         {
             int       itemCount = 0;
             JObject   jsonPeriodicDataResult = JObject.Parse(e.Result);
             JProperty jItemCount;
             if ((jItemCount = jsonPeriodicDataResult.Property("ItemCount")) != null)
             {
                 itemCount = (int)jItemCount.Value;
             }
             Log.Info(typeof(AppReceiverAlarm).Name, "Update task count. {0} - count {1}", DateTime.UtcNow, itemCount);
             ShortcutBadger.ApplyCount(context, itemCount);
         }
     }
     else
     {
         Log.Error(typeof(AppPeriodic).Name, "Error update task count. {0}", DateTime.UtcNow);
     }
 }
Exemple #2
0
        private void RemoveBadgeBtn_Click(object sender, System.EventArgs e)
        {
            bool success = ShortcutBadger.RemoveCount(this);

            Toast.MakeText(ApplicationContext, "success=" + success, ToastLength.Short)
            .Show();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            Bootstrap.Begin(() => new DeviceInstallationService());

            if (DeviceInstallationService.NotificationsSupported)
            {
                FirebaseInstanceId.GetInstance(Firebase.FirebaseApp.Instance)
                .GetInstanceId()
                .AddOnSuccessListener(this);
            }

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            Xamarin.Forms.Forms.Init(this, savedInstanceState);

            LoadApplication(new App());

            CreateNotificationChannel();

            if (!ShortcutBadger.IsBadgeCounterSupported(this))
            {
                Console.WriteLine("Pay attention: badge counter not supported");
            }
        }
Exemple #4
0
 protected override void SetBadgeNumberInternal(int badgeNumber)
 {
     if (_appContext != null)
     {
         var result = ShortcutBadger.ApplyCount(_appContext, badgeNumber);
         Logger.Debug($"Badge count {badgeNumber} was" + (!result ? "NOT" : string.Empty) + "set");
     }
 }
        private void RemoveBadgeCounterOnOlderPlatforms()
        {
            bool isLowerVersion          = Build.VERSION.SdkInt < BuildVersionCodes.O;
            bool isBadgeCounterSupported = ShortcutBadger.IsBadgeCounterSupported(ApplicationContext);

            // Use Plugin for badges on older platforms that support them
            if (isLowerVersion && isBadgeCounterSupported)
            {
                ShortcutBadger.RemoveCount(ApplicationContext);
            }
        }
Exemple #6
0
 private void Button_Click(object sender, System.EventArgs e)
 {
     if (int.TryParse(_numInput.Text, out int badgeCount))
     {
         bool success = ShortcutBadger.ApplyCount(this, badgeCount);
         Toast.MakeText(ApplicationContext, "Set count=" + badgeCount + ", success=" + success, ToastLength.Short)
         .Show();
     }
     else
     {
         Toast.MakeText(ApplicationContext, "Error input", ToastLength.Short)
         .Show();
     }
 }
Exemple #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);

            var editText = FindViewById <EditText>(Resource.Id.badgeValue);
            var button   = FindViewById <Button>(Resource.Id.updateButton);

            button.Click += delegate
            {
                var count = int.Parse(editText.Text);

                ShortcutBadger.ApplyCount(this, count);
            };
        }
Exemple #8
0
        public override void OnCreate()
        {
            base.OnCreate();

            if (ShortcutBadger.IsBadgeCounterSupported(this))
            {
                if (MainActivity.isActivityActive)
                {
                    badgeCount = 0;
                }
                else
                {
                    badgeCount += 1;
                }

                ShortcutBadger.ApplyCount(this, badgeCount);
            }
        }
        public Notification CreateNotification(NotificationViewModel notificationViewModel)
        {
            PendingIntent resultPendingIntent = InitResultIntentBasingOnViewModel(notificationViewModel);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(NotificationContext, _channelId)
                                                 .SetAutoCancel(true)                          // Dismiss the notification from the notification area when the user clicks on it
                                                 .SetContentTitle(notificationViewModel.Title) // Set the title
                                                 .SetContentText(notificationViewModel.Body)   // the message to display.
                                                 .SetContentIntent(resultPendingIntent)        // Start up this activity when the user clicks the intent.
                                                 .SetVibrate(null)
                                                 .SetSound(null)
                                                 .SetNumber(1)
                                                 .SetCategory(NotificationCompat.CategoryMessage)
                                                 .SetOnlyAlertOnce(true);

            // This is the icon to display
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                builder.SetColor(Resource.Color.colorPrimary);
            }

            builder.SetSmallIcon(Resource.Drawable.ic_notification);

            Notification notification = builder.Build();

            bool isLowerVersion          = Build.VERSION.SdkInt < BuildVersionCodes.O;
            bool isBadgeCounterSupported = ShortcutBadger.IsBadgeCounterSupported(NotificationContext);
            bool isMessage = notificationViewModel.Type == NotificationsEnum.NewMessageReceived;
            bool areNotificationsEnabled = NotificationManagerCompat.From(NotificationContext).AreNotificationsEnabled();

            // Use Plugin for badges on older platforms that support them
            if (isLowerVersion &&
                isBadgeCounterSupported &&
                isMessage &&
                areNotificationsEnabled)
            {
                ShortcutBadger.ApplyNotification(NotificationContext, notification, 1);
            }

            return(notification);
        }
Exemple #10
0
        public void UpdateList()
        {
            items = new List <DataGroups>();

            DataSetWS dataSetWS = new DataSetWS();

            string AllowGroupsResult = string.Empty;

            try
            {
                AllowGroupsResult = dataSetWS.GetGroups();
            }
            catch (Exception e)
            {
                mContext.RunOnUiThread(() => {
                    Toast.MakeText(mContext, e.Message, ToastLength.Long).Show();
                    return;
                });
                return;
            }

            JObject jsonResult = JObject.Parse(AllowGroupsResult);

            items.Add(new DataGroups()
            {
                Name = "Главная страница", Description = "Новости", Image = Resource.Drawable.Main, Ref = "", ItemCount = String.Empty
            });
            items.Add(new DataGroups()
            {
                Name = "Сообщения", Description = "", Image = Resource.Drawable.Messages, Ref = "", ItemCount = String.Empty
            });
            int totalItemCount = 0;

            foreach (JObject Group in jsonResult["Data"])
            {
                string Name      = (string)(Group.Property("Name").Value);
                string Ref       = (string)(Group.Property("Ref").Value);
                string ItemCount = Group.Property("ItemCount") == null ? String.Empty : (string)(Group.Property("ItemCount").Value);
                totalItemCount += Group.Property("ItemCount") == null ? 0 : Convert.ToInt16((string)(Group.Property("ItemCount").Value));
                int imageId = 0;
                switch (Name)
                {
                case "Задачи":
                    imageId = Resource.Drawable.Tasks;
                    break;

                case "Справочники":
                    imageId = Resource.Drawable.Directories;
                    break;

                case "Документы":
                    imageId = Resource.Drawable.Documents;
                    break;

                case "Обработки":
                    imageId = Resource.Drawable.DataProcessor;
                    break;

                case "Отчеты":
                    imageId = Resource.Drawable.Reports;
                    break;

                case "Прочее":
                    imageId = Resource.Drawable.Other;
                    break;
                }
                items.Add(new DataGroups()
                {
                    Name = Name, Description = "", Image = imageId, Ref = Ref, ItemCount = ItemCount
                });
            }
            ShortcutBadger.ApplyCount(mContext, totalItemCount);
        }
 /// <summary>
 /// Set the badge number
 /// </summary>
 /// <param name="number">the badge number</param>
 public void SetBadge(int number)
 {
     ShortcutBadger.ApplyCount(Forms.Context, number);
 }
 protected override void OnStart()
 {
     base.OnStart();
     isActivityActive = true;
     ShortcutBadger.ApplyCount(this, 0);
 }