Closed SachinTichkule closed 4 months ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hey @SachinTichkule, thanks for reaching out. Could you answer a few questions below for us to investigate this behavior:
Thanks!
using Unity.Notifications.Android; using UnityEngine; using UnityEngine.Android;
public class Notification : MonoBehaviour { public static string Token { get; private set; } AndroidNotification notification = new AndroidNotification(); AndroidNotificationChannel channel; void Start() { AndroidNotificationCenter.CancelAllNotifications(); Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => { var dependencyStatus = task.Result; if (dependencyStatus == Firebase.DependencyStatus.Available) { var firebase = Firebase.FirebaseApp.DefaultInstance; InitFireBase(); } else { Logger.ShowError(System.String.Format( "Could not resolve all Firebase dependencies: {0}", dependencyStatus)); } }); CreateNotificationChannel(); AskNotificationPermission(); } async void InitFireBase() { Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived; Token = await Firebase.Messaging.FirebaseMessaging.GetTokenAsync(); if(!string.Equals("StubToken",Token)) Logger.ShowMessage(Token); } public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) { Logger.ShowMessage("Received a new message from: " + e.Message.Data); if (!e.Message.NotificationOpened) if (e.Message.Notification != null) SendNotification(e.Message.Notification); } void AskNotificationPermission() { if (!Permission.HasUserAuthorizedPermission("android.permission.POST_NOTIFICATIONS")) { Permission.RequestUserPermission("android.permission.POST_NOTIFICATIONS"); } } void CreateNotificationChannel() { channel = new AndroidNotificationChannel() { Id = "channel_id", Name = "Default Channel", Importance = Importance.Default, Description = "Tambola Game", }; AndroidNotificationCenter.RegisterNotificationChannel(channel);
} void SendNotification(Firebase.Messaging.FirebaseNotification noti) { try { notification.Title = noti.Title; notification.Text = noti.Body; notification.FireTime = System.DateTime.Now; notification.SmallIcon = "small"; notification.LargeIcon = "large";
AndroidNotificationCenter.SendNotification(notification, channel.Id);
}
catch (System.Exception e)
{
Logger.ShowCatchError(e.Message);
}
} void CancelNotification() { AndroidNotificationIntentData data = AndroidNotificationCenter.GetLastNotificationIntent(); if (data != null) AndroidNotificationCenter.CancelNotification(data.Id); }
private void OnApplicationFocus(bool focus) { if (focus) { CancelNotification(); } } }
@argzdev I did not how to produce but it shows in google play store ANR and crash report, yes it shows in every sdk version of firebase which i used
This happens for all our app as well. Firebase v11.6 and v11.9.
The latest release, 12.1.0, https://github.com/firebase/firebase-unity-sdk/releases/tag/v12.1.0, has a potential fix for this issue. Since we weren't able to reproduce this though, this is just based on the call stack. But will close this issue for now, if you still see problems, please let us know.
Description
Unity version 2023.2.16f1 IL2CPP .net standard 2.1 c++ configuration master incremental GC disable Target architecture armv7, arm64 enable armv9 secuirty features for arm64
Reproducing the issue
Playstore Crash and ANR Report
Firebase Unity SDK Version
12.0.0
Unity editor version
2023.2.16f1
Installation Method
.unitypackage
Problematic Firebase Component(s)
Messaging
Other Firebase Component(s) in use
Messaging
Additional SDKs you are using
Facebook, In app review, In app update
Targeted Platform(s)
Android
Unity editor platform
Windows
Scripting Runtime
IL2CPP
Release Distribution Type
Pre-built SDK from https://firebase.google.com/download/unity
Relevant Log Output
If using CocoaPods for Apple platforms, the project's Podfile.lock
Expand
Podfile.lock
snippet```yml 👀 Replace this line with the contents of your Podfile.lock! ```