Reputation: 1125
I'm not sure what else I need to do to get the FCM Token. Perhaps I'm missing a step. Below are the details of my current setup.
This is an Unity iOS build calling GetTokenAsync.
Firebase.Messaging.FirebaseMessaging.GetTokenAsync();
However, I'm getting an exception.
FirebaseException: The operation couldn’t be completed. No APNS token specified before fetching FCM Token
I've generated an APN Key for push notification and uploaded to Firebase, but I'm not sure do I need to included it somehow with Xcode?
I've enabled Background Modes.
Upvotes: 2
Views: 17284
Reputation: 75
I changed
async void InitializeFirebase()
{
FirebaseMessaging.MessageReceived += OnMessageReceived;
FirebaseMessaging.TokenReceived += OnTokenReceived;
}
to
async void InitializeFirebase()
{
FirebaseMessaging.MessageReceived += OnMessageReceived;
await RegenerateFcmToken();
}
private async 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 (Exception e)
{
Log(e.Message);
throw;
}
}
And I don't have the message "No APNS token specified before fetching FCM Token" anymore
Upvotes: 0
Reputation: 1
use following pod version it will work
pod 'Firebase/Messaging', '10.6.0'
add following properties in info.plist
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
Upvotes: 0
Reputation: 73
You should use last version of firebase_message and firebase_core.
firebase_core: ^2.17.0
firebase_messaging: ^14.6.9
this will work fine.
Upvotes: -1
Reputation: 347
There are multiple reasons this could be happening. The following instruction steps are included in the Set up FCM for Unity Guide.
Try each of the following (if you haven't already):
If this doesn't work then look through the logs before and after the message you are getting above and see if there are earlier messages relating to warnings or failures with FCM or APNS.
Please tell me how it works out for you.
Upvotes: 2