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
.
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)
{
}
}
Also I added in the AndroidManifest.xml
<application>
<service android:name="PushNotificationListener" />
</application>
What is the correct implementation for Android
? Is there anything to add in the AndroidManifest.xml
?