Reputation: 353
I'm trying to build a Flutter app for both Android and iOS. I've been implementing push notifications using Firestore Cloud Messaging (FCM) and it works for both Android and iOS when I'm testing on a simulator (Android) or on a connected physical device (iOS).
However, when I build the app for the client to test (using Codemagic), the push notifications are not working on iOS (it does on Android). If it works on my development environment but not on Codemagic, that means everything is configured correctly except for Codemagic's build, right??
I don't think there's an additional configuration to be done on Codemagic besides connecting the apple developer account. But if I had done a mistake connecting the account, then the team wouldn't show up when I'm building the app I suppose.
Also, when I try sending a push notification via Postman using the FCM token generated by the iphone, it returns "NotRegistered".
So what am I doing wrong?
Please, any help would be greatly appreciated.
Thanks.
Upvotes: 2
Views: 1447
Reputation: 21
Iam kinda late, but maybe someone is still facing this problem and looking for a solution. I also got NotRegistered on every message I wanted to send to my IOS devices. My problem was, that the FCM IOS Key I was creating was a sandbox key. APNS uses two servers for push notifications- SandBox & Production. When you build a debug version of the app on the iOS device during development it connects to the SandBox server and retrieves token from it. Once you create a release build of the app, it will connect to the production server. If you are testing the app with debug build then to test the notifications you need to ensure that you test it through sandbox. Once you receive the token you can use the below Google API to convert APNS token to FCM token:
HTTP POST : https://iid.googleapis.com/iid/v1:batchImport HTTP HEADERS: Content-Type: application/json Authorization : key=YOUR_SERVER_KEY
Body :
{ "application": "com.company.app", (YOUR_APP_PACKAGE) "sandbox":true, "apns_tokens":["7c6811bfa1e89c739c5862122aa7ab68fc4972dea7372242f74276a5326f...."] }
Upvotes: 0
Reputation: 786
I would try to check the provisioning profile that is being used by Codemagic during the build. If you already tried to use Automatic code signing on Codemagic, and added FCM later on, then you might have to delete the provisioning profile already created by Codemagic to force Codemagic to create a new one with Push Notifications enabled (once they have been enabled in xcode capabilities). In any case you can check the generated profile on Apple Developer Portal, and check whether the push notifications are enabled for the generated profile.
Upvotes: 2
Reputation: 353
In case anyone is having the same problem. I solved this simply by not using Codemagic for iOS deployment. I followed this guide instead: https://flutter.dev/docs/deployment/ios and deployed the iOS build on Apple's TestFlight.
The push notifications worked great on iOS after installing the app from there.
Upvotes: 0
Reputation: 904
For iOS the application identifier requires a production and a development certificate. If it only has the development certificate, it will only work in development. Are you giving the customer a distribution build or development build?
Upvotes: 0