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;await FirebaseMessaging.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.await FirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(task =>{ LogTaskCompletion(task,"RequestPermissionAsync");});isFirebaseInitialized=true;}publicvoidOnTokenReceived(objectsender,TokenReceivedEventArgstoken){
Debug.Log("Received Registration Token: "+ token.Token);}
to
asyncvoidInitializeFirebase(){
FirebaseMessaging.MessageReceived +=OnMessageReceived;await RegenerateFcmToken();await FirebaseMessaging.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.await FirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(task =>{ LogTaskCompletion(task,"RequestPermissionAsync");});isFirebaseInitialized=true;}privateasync Task RegenerateFcmToken(){try{
Log("Requesting new FCM Registration Token ...");await FirebaseMessaging.DeleteTokenAsync();await FirebaseMessaging.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 :
using System.Collections;using System.Collections.Generic;using UnityEngine;using Firebase.Messaging;using TMPro;using System.Net;using Firebase.Extensions;using System;using System.Threading.Tasks;publicclassFCM:MonoBehaviour{[SerializeField]TextMeshProUGUImessageText;boolisFirebaseInitialized;stringfcmToken="";stringtopic="dates";
Firebase.DependencyStatus dependencyStatus= Firebase.DependencyStatus.UnavailableOther;asyncpublicvoidStart(){
Debug.Log("IN START");await Firebase.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*/await RegenerateFcmToken();//endifawait FirebaseMessaging.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.await FirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(task =>{ LogTaskCompletion(task,"RequestPermissionAsync");});isFirebaseInitialized=true;}publicvoidOnTokenReceived(objectsender,TokenReceivedEventArgstoken){
Debug.Log("Received Registration Token: "+ token.Token);}privateasync Task RegenerateFcmToken(){try{//bug connu, le token n'est pas régénéré par défaut : https://github.com/firebase/quickstart-unity/issues/1088
Log("Requesting new FCM Registration Token ...");await FirebaseMessaging.DeleteTokenAsync();await 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});}catch(Exceptione){
Log(e.Message);throw;}}publicvoidOnMessageReceived(objectsender, Firebase.Messaging.MessageReceivedEventArgs e){
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> iter in
e.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(Exception exception in task.Exception.Flatten().InnerExceptions){stringerrorCode="";
Firebase.FirebaseException firebaseEx= exception as Firebase.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...");await Firebase.Messaging.FirebaseMessaging.DeleteTokenAsync();
Log("FCM Token deleted.");}publicasyncvoidUI_GetNewToken(){
Log("Requesting new FCM Token...");await Firebase.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...");await FirebaseMessaging.SubscribeAsync(topic).ContinueWithOnMainThread(task =>{ LogTaskCompletion(task,"SubscribeAsync");});await FirebaseMessaging.SubscribeAsync($"/topics/{topic}").ContinueWithOnMainThread(task =>{ LogTaskCompletion(task,"SubscribeAsync");});
Log("Subscribed to dates");}publicasyncvoidUI_UnsubscribeFromDates(){
Log("Pressed unsubscribe...");await FirebaseMessaging.UnsubscribeAsync(topic).ContinueWithOnMainThread(task =>{ LogTaskCompletion(task,"SubscribeAsync");});await FirebaseMessaging.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: