I have an issue with push notifications not being received on an iOS device in my Flutter app.
I tried to follow this guide: https://firebase.flutter.dev/docs/messaging/apple-integration/
Steps I have made to configure my push notifications:
- Register my APN from developer.apple.com on Firebase Console (Cloud Messaging -> my app)
- Used the GoogleServices-Info.plist from firebase
- Built the app and uploaded to TestFlight
- Asked the user for permission to show notifications on iOS
- Copied the fcm token from my app and pasted it into Firebase Console -> Cloud Messaging -> new campaign
- Push has not been received by my physical iPhone that has the app installed from TestFlight.
I also have made sure I have XCode configured properly and:
- I have selected Push Notifications and Background Modes (Background fetch, Remote notifications)
- I am using the proper bundle identifier (lol)
- My App ID has Push Notifications selected
- My APN key has the Push Notifications Service selected
Any idea on what I am doing wrong? Anyone experienced a similar issue?
EDIT:
This is my AppDelegate.swift
file, maybe it's somewhat helpful in resolving my issue (worth mentioning - I didn't touch it, it's generated by flutter I guess):
import UIKit
import Flutter
import FirebaseMessaging
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
super.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
}
Also have received such an email from Apple when submitted a build to Test Flight:
EDIT:
I have checked my .entitlements
file and it says production
. I also checked the Payload/AppName.app/embedded.mobileprovision
and it also says production
.
I also have added the APNs certificate in Firebase Messaging:
I connected my iPhone 8 to my MacBook and opened the console app for my iPhone 8. I found out, that when I launch my app, the console says:
No valid 'aps-environment' entitlement string found for application 'pl.mycompany.myproject.myapp': (null).
I suspect, it could be related to me signing, building and uploading the app using Fastlane, since I do have my aps-environment
set to development
when uploading in my myapp/ios/Runner/Runner.entitlements
I also get those prints in the console:
[pl.mycompany.myproject.myapp] Push registration with a nil environment was encountered, will not invalidate token
[pl.mycompany.myproject.myapp] Ignore becoming foreground for application without push registration