Reputation: 193
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:
I also have made sure I have XCode configured properly and:
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
Upvotes: 5
Views: 17271
Reputation: 1
Delete your key in your developer account, and create another one, and upload it again on your firebase. That will solve your problem.
Upvotes: -3
Reputation: 1790
2. Use Flutter you don't need to import FirebaseMessigng in AppDelegate.
- Just import Firebase
then call FirebaseApp.configure()
in application
func.
- If you configure firebase and newest documents use firebase cli instead of GoogleServices-Info.plist you even don't need modify your AppDelegate
https://firebase.flutter.dev/docs/cli/
Did you call await Firebase.initializeApp();
after call WidgetsFlutterBinding.ensureInitialized();
and before build your app?
I think you should try local script to push notification to ensure
your configuration is right.
xcrun simctl push simulator-device-id app-bundle-id notification.apns
with notification.apns is file contains payload test, for example:
{ "aps": { "alert": "APNs demo", "sound": "default", "badge": 69 } }
https://sarunw.com/posts/testing-remote-push-notification-in-ios-simulator/
Upvotes: 0
Reputation: 646
Basing from experience I'm assuming the push notification is working when in debug mode right?
Funnily enough in my case the APNS Cert was only for development double check your apns certificate that might be the culprit!! :)
or might as well remake the certs ~
Upvotes: 0
Reputation: 1092
The ITMS-90078 issue you're getting from the App Store indicates that the final app signature's entitlements is missing the aps-environment
entry. Thus, Push Notifications may not work as expected with TestFlight builds.
First, make sure that all of the .entitlements
files in your Xcode project do contain the said entry with the appropriate value (usually development
or production
).
Secondly, on the machine used to build the app, make sure that the local copy of the provisioning profile at ~/Library/MobileDevice/Provisioning\ Profiles
does contain the aps-environment
entry. If it does not, you should download the provisioning profile again and replace your local copy.
Ultimately, to verify that the final provisioning profile does contain the aps-environment
value, you could unzip the built IPA and navigate to Payload/AppName.app/embedded.mobileprovision
. You may check that the Entitlements section actually contains that key with the expected value.
If not, your entitlement file(s) or provisioning profiles could be altered by one of the build phases (which is a lot less likely).
Upvotes: 3