Push notifications not working in IOS(flutter)

When I test the push through the APNs push notification tester, “Couldn’t send push notification.Status: 400 (BadDeviceToken)” occurs.

I also checked the Push token in User information, and I also checked the tokens on the device. What is problem?

  • Translated into a translator *

Hi @arica,

Welcome to the Sendbird Community. Can you show me how you’re registering tokens on the Flutter SDK? With Flutter, it sounds like you might be registering an FCM token for APNS or vice versa.

Thank you for your welcome, @Tyler

              if (token != null) sendbird.registerPushToken(type: Platform.isIOS ? PushTokenType.apns : PushTokenType.fcm,token: token);

I’m registering token with the code above.

For iOS, you would need to obtain an APNS token, not a FCM token. Sendbird only sends tokens to iOS devices via APNS.

I believe firebase has a method to retrieve apns token, you may want to use it for iOS instead getToken

Using getAPNSToken, I’m getting a push from the APNs push notification tester and the real app. Thank you. @Woo @Tyler

But I can’t get an app push on the foreground. What should I do about this? I am sorry that I know very little as a beginner.

“Send to devices both offline and online” have been activated.
“userNotificationCenter” was also overrided at AppDelegate, but it was not delivered.

For foreground push, our server does not support for flutter yet and we are about to add this soon! Thanks for your patient.

OK, thank you! X-D

+) I solved it by making a local push in OnMessageReceived!

1 Like