-1

I have created a Xamarin.Forms app, but I am oriented to android platform. I have released the app in 2 devices: Samsung (Android 6.0 API 23) and Huawei (Android 6.0 API 23), the problem is on the huawei device, which when I want to create a local notification that it needs to be displayed when app is breaked, (by creating a broadcast receiver, etc) it is not displayed, otherwise on samsung it is, im sure that the problem is not on the code (is obvious, the code is not specialized on an specific device), so I believe more that the problem is on my huawei device, any suggestions for this problem??

CODE FOR CREATING THE NOTIFICATIONS

Method that is called when user click on “notify button” to shedule repeated notificacions:

 public static void EstablishNotification(long startSeconds)
            => alarmManager.SetRepeating(
                AlarmType.ElapsedRealtimeWakeup,
                SystemClock.ElapsedRealtime() + (startSeconds * 1000),
                3600 * 1000, pendingIntent);

Broadcast receiver on binded to intent on alarm manager

public override void OnReceive(Context context, Intent intent)
        {
            if (intent?.Extras != null)
            {
                title = intent.Extras.GetString(AndroidNotificationManager.TitleKey);
                message = intent.Extras.GetString(AndroidNotificationManager.MessageKey);
            }

            var id = intent.Extras.GetInt(AndroidNotificationManager.ID);

            Intent _intent = new Intent(AndroidApp.Context, typeof(SplashActivity));
            _intent.PutExtra(TitleKey, title);
            _intent.PutExtra(MessageKey, message);
            _intent.PutExtra(ID, id); 

            PendingIntent pendingIntent = PendingIntent.GetActivity(
                AndroidApp.Context,
                id, _intent,
           PendingIntentFlags.OneShot);

            NotificationCompat.Builder builder = new NotificationCompat.Builder(AndroidApp.Context, channelId)
               .SetContentIntent(pendingIntent)
               .SetContentTitle(title)
               .SetContentText(message)
               .SetLargeIcon(BitmapFactory.DecodeResource(AndroidApp.Context.Resources, Resource.Drawable.SortexAppIcon))
               .SetSmallIcon(Resource.Drawable.SortexAppIcon)
               .SetDefaults((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate);

            manager = 
                (NotificationManager)context.GetSystemService(
                    AndroidApp.NotificationService);

            var notification = builder.Build();
            manager.Notify(messageId, notification);

2 Answers2

0

Methods,Firstly, Find "Settings" in the mobile phone, click to enter, and find "notification management". Second, Click to enter "notice management", which includes "notice management" and "suspended window management", showing"notice management". Forth, In "notice management", find the application which need to be opened. Click "enter" , the corresponding options will be displayed,selectting "prompt" or "allow".

Following is a detailed Chinese text and picture introduction, https://zhidao.baidu.com/question/1695787110911971788.html

Mary
  • 1