You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Other Firebase Components in use: Firestore + Storage + Auth are in the project files but not in this test scene
Additional SDKs you are using: None
Platform you are using the Unity editor on: Windows
Platform you are targeting: iOS
Scripting Runtime: IL2CPP
[REQUIRED] Please describe the issue here:
(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)
Steps to reproduce:
I had this error on iOS :
No APNS token specified before fetching FCM Token
I changed
asyncvoidInitializeFirebase(){FirebaseMessaging.MessageReceived+=OnMessageReceived;FirebaseMessaging.TokenReceived+=OnTokenReceived;awaitFirebaseMessaging.SubscribeAsync(topic).ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});Log("Firebase Messaging Initialized");// On iOS, this will display the prompt to request permission to receive// notifications if the prompt has not already been displayed before. (If// the user already responded to the prompt, thier decision is cached by// the OS and can be changed in the OS settings).// On Android, this will return successfully immediately, as there is no// equivalent system logic to run.awaitFirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(
task =>{LogTaskCompletion(task,"RequestPermissionAsync");});isFirebaseInitialized=true;}publicvoidOnTokenReceived(objectsender,TokenReceivedEventArgstoken){Debug.Log("Received Registration Token: "+token.Token);}
to
asyncvoidInitializeFirebase(){FirebaseMessaging.MessageReceived+=OnMessageReceived;awaitRegenerateFcmToken();awaitFirebaseMessaging.SubscribeAsync(topic).ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});Log("Firebase Messaging Initialized");// On iOS, this will display the prompt to request permission to receive// notifications if the prompt has not already been displayed before. (If// the user already responded to the prompt, thier decision is cached by// the OS and can be changed in the OS settings).// On Android, this will return successfully immediately, as there is no// equivalent system logic to run.awaitFirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(
task =>{LogTaskCompletion(task,"RequestPermissionAsync");});isFirebaseInitialized=true;}privateasyncTaskRegenerateFcmToken(){try{Log("Requesting new FCM Registration Token ...");awaitFirebaseMessaging.DeleteTokenAsync();awaitFirebaseMessaging.GetTokenAsync().ContinueWithOnMainThread(task =>{if(task.Exception!=null){Log(task.Exception.Message);return;}fcmToken=task.Result;Log("Received Registration Token: "+fcmToken);});}catch(Exceptione){Log(e.Message);throw;}}
And I don't have the error anymore.
However, I still can't receive notification push on my iOS Device
Remote Notification is checked & Push Notification is here.
UserNotifications.framework is here too
my APN key is uploaded in Firebase :
Relevant Code:
this is my FCM.cs script which is some copy paste from yours from the sample :
usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingFirebase.Messaging;usingTMPro;usingSystem.Net;usingFirebase.Extensions;usingSystem;usingSystem.Threading.Tasks;publicclassFCM:MonoBehaviour{[SerializeField]TextMeshProUGUImessageText;boolisFirebaseInitialized;stringfcmToken="";stringtopic="dates";Firebase.DependencyStatusdependencyStatus=Firebase.DependencyStatus.UnavailableOther;asyncpublicvoidStart(){Debug.Log("IN START");awaitFirebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>{dependencyStatus=task.Result;if(dependencyStatus==Firebase.DependencyStatus.Available){Log("Firebase available");InitializeFirebase();}else{Debug.LogError("Could not resolve all Firebase dependencies: "+dependencyStatus);}});}// Setup message event handlers.asyncvoidInitializeFirebase(){FirebaseMessaging.MessageReceived+=OnMessageReceived;/*#if UNITY_IPHONE FirebaseMessaging.TokenReceived += OnTokenReceived;#endif#if UNITY_ANDROID*/awaitRegenerateFcmToken();//endifawaitFirebaseMessaging.SubscribeAsync(topic).ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});Log("Firebase Messaging Initialized");// On iOS, this will display the prompt to request permission to receive// notifications if the prompt has not already been displayed before. (If// the user already responded to the prompt, thier decision is cached by// the OS and can be changed in the OS settings).// On Android, this will return successfully immediately, as there is no// equivalent system logic to run.awaitFirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(
task =>{LogTaskCompletion(task,"RequestPermissionAsync");});isFirebaseInitialized=true;}publicvoidOnTokenReceived(objectsender,TokenReceivedEventArgstoken){Debug.Log("Received Registration Token: "+token.Token);}privateasyncTaskRegenerateFcmToken(){try{//bug connu, le token n'est pas régénéré par défaut : https://github.com/firebase/quickstart-unity/issues/1088Log("Requesting new FCM Registration Token ...");awaitFirebaseMessaging.DeleteTokenAsync();awaitFirebaseMessaging.GetTokenAsync().ContinueWithOnMainThread(task =>{if(task.Exception!=null){Log(task.Exception.Message);return;}fcmToken=task.Result;Log("Received Registration Token: "+fcmToken);//On pourrait appeler une cloud function ici pour stocker ce token dans Firestore pour envoyer des notifications ciblées});}catch(Exceptione){Log(e.Message);throw;}}publicvoidOnMessageReceived(objectsender,Firebase.Messaging.MessageReceivedEventArgse){Log("Received a new message");Log($"Message opened : {e.Message.NotificationOpened}\n",true);varnotification=e.Message.Notification;if(notification!=null){Log("title: "+notification.Title,true);Log("body: "+notification.Body,true);varandroid=notification.Android;if(android!=null){Log("android channel_id: "+android.ChannelId,true);}}if(e.Message.From.Length>0){Log("from: "+e.Message.From,true);}if(e.Message.Link!=null){Log("link: "+e.Message.Link.ToString(),true);}if(e.Message.Data.Count>0){Log("data:",true);foreach(KeyValuePair<string,string>iterine.Message.Data){Log(" "+iter.Key+": "+iter.Value,true);}}}voidLog(stringmessage,boolnewLine=false){if(newLine){messageText.text+=$"\n{message}";Debug.Log(message);}else{Debug.Log(messageText.text=message);}}// Log the result of the specified task, returning true if the task// completed successfully, false otherwise.protectedboolLogTaskCompletion(Tasktask,stringoperation){boolcomplete=false;if(task.IsCanceled){Log(operation+" canceled.");}elseif(task.IsFaulted){Log(operation+" encounted an error.");foreach(Exceptionexceptionintask.Exception.Flatten().InnerExceptions){stringerrorCode="";Firebase.FirebaseExceptionfirebaseEx=exceptionasFirebase.FirebaseException;if(firebaseEx!=null){errorCode=string.Format("Error.{0}: ",((Firebase.Messaging.Error)firebaseEx.ErrorCode).ToString());}Log(errorCode+exception.ToString());}}elseif(task.IsCompleted){Log(operation+" completed");complete=true;}returncomplete;}publicasyncvoidUI_DeleteCurrentToken(){Log("Deleting current FCM Token...");awaitFirebase.Messaging.FirebaseMessaging.DeleteTokenAsync();Log("FCM Token deleted.");}publicasyncvoidUI_GetNewToken(){Log("Requesting new FCM Token...");awaitFirebase.Messaging.FirebaseMessaging.GetTokenAsync().ContinueWithOnMainThread(task =>{if(task.Exception!=null){Log(task.Exception.Message);return;}fcmToken=task.Result;Log("Received Registration Token: "+fcmToken);//On pourrait appeler une cloud function ici pour stocker ce token dans Firestore pour envoyer des notifications ciblées});}publicasyncvoidUI_SubscribeToDates(){Log("Pressed subscribe...");awaitFirebaseMessaging.SubscribeAsync(topic).ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});awaitFirebaseMessaging.SubscribeAsync($"/topics/{topic}").ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});Log("Subscribed to dates");}publicasyncvoidUI_UnsubscribeFromDates(){Log("Pressed unsubscribe...");awaitFirebaseMessaging.UnsubscribeAsync(topic).ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});awaitFirebaseMessaging.UnsubscribeAsync($"/topics/{topic}").ContinueWithOnMainThread(task =>{LogTaskCompletion(task,"SubscribeAsync");});Log("Unsubscribed from dates");}}
The text was updated successfully, but these errors were encountered:
[REQUIRED] Please fill in the following fields:
[REQUIRED] Please describe the issue here:
(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)
Steps to reproduce:
I had this error on iOS :
No APNS token specified before fetching FCM Token
I changed
to
And I don't have the error anymore.
However, I still can't receive notification push on my iOS Device
Remote Notification is checked & Push Notification is here.
UserNotifications.framework is here too
my APN key is uploaded in Firebase :
Relevant Code:
this is my FCM.cs script which is some copy paste from yours from the sample :
The text was updated successfully, but these errors were encountered: