Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Push Notification with AppCenter when the app is closed

$
0
0

Hi guys,
I'm implementing Push Notification in my app with AppCenter. In UWP I created a background service to receive message when the app is closed. I'm trying to do the same with Android and, later, iOS.

In Android project I created a IntentService to initialize the Push from AppCenter but it doesn't work.

[Service]
public class PushNotificationService : IntentService
{
    public override void OnCreate()
    {
       if (!AppCenter.Configured)
        {
            Push.PushNotificationReceived += (sender, e) =>
            {
                new NotificationHelpers().ShowNotification(e.Title, e.Message, e.CustomData);
            };
        }
    }

    public override IBinder OnBind(Intent intent)
    {
        return null;
    }

    [return: GeneratedEnum]
    public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId)
    {
        return StartCommandResult.StickyCompatibility;
    }

    protected override void OnHandleIntent(Intent intent)
    {
    }
}

What is the correct implementation for Android? Thank you


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>