I have a problem with fcm token receiving on TestFlight.
All seems to work good while testing on both Android and iOS simulators. But running app on TestFlight fails with such error message:
[firebase_messaging/unknown] An unknown error has occurred
Error causing line:
await FirebaseMessaging.instance.getToken()
I use these packages version:
firebase_core: ^2.8.0
firebase_messaging: ^14.3.0
Flutter & Dart versions:
Flutter 3.7.8 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 90c64ed42b (5 days ago) • 2023-03-21 11:27:08 -0500
Engine • revision 9aa7816315
Tools • Dart 2.19.5 • DevTools 2.20.1
Sure, I use the APNs authorization key and all needed capabilities are enabled.
I have already tried to create a new app and did all the initialization steps again with new API keys etc., but result is the same.
2
Answers
The problem was not enabled the Push Notifications capability through XCode.
It’s hard to say based on this.
Have you Check enabled Push Notifications in the App ID section of your Apple Developer account? You must make sure that you have uploaded the correct APNs authentication key to Firebase console.
Check the bundle identifier of your app on TestFlight matches the one on Firebase console.
Try using FirebaseMessaging.instance.requestPermission() to request permission to send notifications to your device.