Firebase teszthez

This commit is contained in:
2025-05-15 09:28:08 +02:00
parent 7efd090b86
commit 9df2854a3c
6 changed files with 86 additions and 5 deletions
@@ -3,6 +3,8 @@ using Android.Content;
using Android.Content.PM;
using Android.Nfc;
using Android.OS;
using Firebase;
using Plugin.Firebase.CloudMessaging;
using Plugin.NFC;
@@ -40,12 +42,14 @@ namespace WorkFlowCheck.MAUI
new Intent(this, typeof(MainActivity)).AddFlags(ActivityFlags.SingleTop),
Build.VERSION.SdkInt >= BuildVersionCodes.S ? PendingIntentFlags.Mutable : PendingIntentFlags.UpdateCurrent);
HandleIntent(Intent);
CreateNotificationChannelIfNeeded();
}
protected override void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);
HandleIntent(intent);
CrossNFC.OnNewIntent(intent);
if (intent.Action == NfcAdapter.ActionTagDiscovered)
@@ -85,5 +89,24 @@ namespace WorkFlowCheck.MAUI
// nfcAdapter?.DisableForegroundDispatch(this);
//}
}
private static void HandleIntent(Intent intent)
{
FirebaseCloudMessagingImplementation.OnNewIntent(intent);
}
private void CreateNotificationChannelIfNeeded()
{
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
{
CreateNotificationChannel();
}
}
private void CreateNotificationChannel()
{
var channelId = $"{PackageName}.general";
var notificationManager = (NotificationManager)GetSystemService(NotificationService);
var channel = new NotificationChannel(channelId, "General", NotificationImportance.Default);
notificationManager.CreateNotificationChannel(channel);
FirebaseCloudMessagingImplementation.ChannelId = channelId;
}
}
}