I'm using Xamarin.Forms but I'm having a few problems handling push notifications. **They only work fine when app is in foreground.**

When the app is in background, all notifications are received and displayed correctly but I can't manage to get them to vibrate or even turn led on. I have found a lot of documentation but it's pretty old and most of the time, methods referred are deprecated. 

Anyway, I have a *FirebaseMessagingService* to handle FCM events and this is the action that generates the push notification:

```
    void SendNotification(RemoteMessage message)
    {
        var intent = new Intent(this, typeof(MainActivity));
        intent.AddFlags(ActivityFlags.ClearTop);

        intent.PutExtra("type", message.Data["type"]);

        var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);

        NotificationManager notificationManager = (NotificationManager)ApplicationContext.GetSystemService(NotificationService);
        NotificationCompat.Builder builder = null;

        if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
        {
            var importance = NotificationImportance.Default;
            NotificationChannel notificationChannel = new NotificationChannel("ID", "Name", importance);
            notificationManager.CreateNotificationChannel(notificationChannel);
            builder = new NotificationCompat.Builder(ApplicationContext, notificationChannel.Id);
        }
        else
            builder = new NotificationCompat.Builder(ApplicationContext);

        builder = builder
            .SetSmallIcon(Resource.Drawable.icon)
            .SetDefaults((int)((int)NotificationDefaults.Sound | (int)NotificationDefaults.Vibrate))
            .SetAutoCancel(true)
            .SetContentTitle(message.GetNotification().Title)
            .SetContentText(message.GetNotification().Body)
            .SetContentIntent(pendingIntent)
            .SetLights(65536, 1000, 500)
            .SetVibrate(new long[] { 1000, 1000, 1000 })
            .SetPriority((int)NotificationPriority.High);

        PowerManager pm = (PowerManager)ApplicationContext.GetSystemService(PowerService);

        WakeLock wl = pm.NewWakeLock(WakeLockFlags.Partial, "TAG");

        wl.Acquire(15000);

        notificationManager.Notify(0, builder.Build());

        wl.Release();

    }

```

I also added these lines in the Android.Manifest file:

```
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE"/>

```

**It was pretty much simpler before** but I've been adding new things trying to make it work, like the WAKE\_LOCK section or the distinction of Android Version when creating the Builder object. **It vibrates only when app is in foreground.** 

I even tried using the James Montemagno's Vibrate Plugin or using Android.Vibrator class and they didn't work either when app is in background. 

I'm open to suggestions here. Thanks.