Flutter Push notification not displaying on IOS

apple-push-notificationsdartflutter

I am having an issue with Flutter and IOS in regards to Push notifications.

My setup and things that work:

1) I installed the firebase_messaging: ^5.1.6 package with no errors / followed all their instructions for IOS

2) I have asked user permission on IOS and accepted to receive push notifications

3) I am able to get an FCM token on IOS & Android devices

4) I have created a Key in the Apple developer section and added the key to FCM

5) I have closed the app / sent it to the background when testing – still no luck

6) I have added the google-service-info file to Runner using Xcode

7) I have added push notifications and background notifications in XCode Capabilities

8) I am testing on an iPhone 7 physical device, and a physical iPad

I have used curl to send a notification to an IOS device

curl -X POST --header "Authorization: key=<myAuthKEY>" \
    --Header "Content-Type: application/json" \
    https://fcm.googleapis.com/fcm/send \
    -d "{\"to\":\"<myDeviceKey>\",\"notification\":{\"body\":\"Hello\"},\"priority\":10}"

I get a success response from firebase

{"multicast_id":<SomeIdHere>,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"<SomeIdHere>"}]}

Here is how I retrieve the token:

firebaseMessaging.getToken().then((String token) {
      _authModel.setNotificationToken(token);
    });

When I run the app on IOS, I do not get any Firebase errors.

I've been messing around with this for 2 days now, so it's getting a bit annoying, all the above seems to work on Android.

Any suggestions, please.

Flutter Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.9.1+hotfix.4, on Mac OS X 10.15 19A583, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.0)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.38.1)
[✓] Connected device (4 available)

• No issues found!

My AppDelegate.m file

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
@import Firebase;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [FIRApp configure];
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Override point for customization after application launch.
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end

Best Answer

It's not pretty, you may need to provide a lot more details, but please file this issue to https://github.com/FirebaseExtended/flutterfire/issues. Otherwise, a quick search of iOS push notification issues shows variety of reports. Here are some similar ones, maybe one is related yours?

Or if you already filed one, share the link! Others may add feedback to yours.

Related Topic