I want to hide android app when app is completely closed.When app is open it works but when app is closed doesn`t.I use firebase notification to reactivate app by sending notification(OnMessageRecieved).
It works when app is open but it dosen`t work when app is closed.It should work beacause I saw that in diffrent frameworks like android studio it works.But I want it to work with maui.This is my code:
using Android.App;
using Android.Content;
using Android.Content.PM;
using AndroidX.Core.App;
using Firebase.Messaging;
using Plugin.Firebase.CloudMessaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Intent = Android.Content.Intent;
using Androidapp = Android.App.Application;
using static Android.Icu.Text.CaseMap;
using static Android.Provider.Settings;
using AnotherTestMaui;
namespace AnotherTestMaui.Platforms.Android
{
[Service(Exported = true)]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
public class FireFire : FirebaseMessagingService
{
Context a = null;
public FireFire()
{
}
public override void OnCreate()
{
base.OnCreate();
a = this;
}
public override void OnNewToken(string token)
{
base.OnNewToken(token);
if (Preferences.ContainsKey("DeviceToken"))
{
Preferences.Remove("DeviceToken");
}
Preferences.Set("DeviceToken", token);
}
public override void OnMessageReceived(RemoteMessage message)
{
base.OnMessageReceived(message);
PackageManager.SetComponentEnabledSetting(MainActivity.ActivityCurrent.ComponentName, ComponentEnabledState.Disabled, ComponentEnableOption.DontKillApp);
}
}
}````
New contributor
user26743315 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.