How to show a push notification on the iOS lock screen using flutter and FCM

Asked

Viewed 430 times

-1

I followed several tutorials and am unable to show on the lock screen on iphone the notification using flutter and FCM. I followed the steps:

  1. I enabled my app on my apple account for notifications
  2. I imported the development and production certificates to firebase cloud
  3. Exlcui all provisions to avoid conflicts of my mac
  4. I created new provisioning for production and development
  5. I set Xcode 11 + compatible for backgound and push notification
  6. I entered the code below in the delegate
if #available(iOS 10.0, *) {
  UNUserNotificationCenter.current().delegate = self as? 
 UNUserNotificationCenterDelegate
}
  1. I entered it in info.plist

    Firebaseppdelegateproxyenabled as fake, tried string NO and gave in it.

  2. I made the request for permission to notify first of all. I followed all the step-by-step of the plugin’s official website firebase_messaging

I receive the message in the method onmessage, onLaunch using the code below and I see the message sent in the console of android studio or Xcode:

_firebaseMessaging.configure(
  onMessage: (Map<String, dynamic> message) async {
    print("onMessage: $message");

  },

  onLaunch: (Map<String, dynamic> message) async {
    print("onLaunch: $message");

  },
  onResume: (Map<String, dynamic> message) async {
    print("onResume: $message");

  },
);

I’m using Postman to send the message:

  {"notification":{"title":"Conteúdo liberado","body":"O conteúdo foi 
  liberado Veja e confira as novidades"},"data":{"click_action": 
  "FLUTTER_NOTIFICATION_CLICK","nome":" ","type":"recursos","title":"Conteúdo 
  liberado","body":"Conteúdo liberado veja e confira as novidades", 
 "icon":"user.svg"},"registration_ids":["xxxxxx"]}

For android everything works and shows on the lock screen, but I’m not able to show the notification on the iOS lock screen, the vast majority of tutorials focuses only on Android and very superficial speech with iOS.

Does anyone have any tips? I have 3 weeks looking for this solution. I believe it is some native Xcode configuration that is missing.

1 answer

1


After a lot of research, I found the problem. In the plugin’s official documentation firebase_messaging

does not say that the "Xcode" does not include the entitlements file reference for the build in debug and release mode. Just copy the reference(file path) Runnerprofile.entitlements at the location indicated in yellow that everything worked.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.