How to get Push-Notification on iOS working with Firebase and Flutter?
The documentation for flutter_local_notifications states the following:
NOTE: this plugin registers itself as the delegate to handle incoming notifications and actions. This may cause problems if you're using other plugins for push notifications (e.g. firebase_messaging) as they will most likely do the same and it's only possible to register a single delegate.
A few questions:
- Why do you want to utilise both packages?
- Have you enabled
Remote notifications
inBackground Modes
under yourTarget
in Xcode? - Have you created a certificate for notifications on iOS? (APNS: Apple Push Notification Service (link)
Let me know how this turns out for you :)
Admin
Updated on December 11, 2022Comments
-
Admin over 1 year
I tried many different tutorials, followed e.g. this one https://medium.com/flutterpub/enabling-firebase-cloud-messaging-push-notifications-with-flutter-39b08f2ed723
But I'm not able to receive any Push-Notifications on my iPhone. It works perfectly on Android.
I use firebase_messaging: ^4.0.0+4 and flutter_local_notifications: ^0.6.1
The problem is that none of the listeners (onMessage, onResume or onLaunch) is getting called in iOS although a token is received with getToken()
There is no error message. I can't find the reason for this behavior. I would be glad if someone could help me out.
Thanks.
_firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) async { print("IM HERE ON MESSAGE"); print('on message $message'); String message_as_String = json.encode(message); print(message_as_String); String title = "test"; String body = "test"; String screen = "test"; var androidPlatformChannelSpecifics = new AndroidNotificationDetails( 'your channel id', 'your channel name', 'your channel description', playSound: false, importance: Importance.Max, priority: Priority.High); var iOSPlatformChannelSpecifics = new IOSNotificationDetails(presentSound: false); var platformChannelSpecifics = new NotificationDetails( androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics); await flutterLocalNotificationsPlugin.show( 0, body, title, platformChannelSpecifics, payload: screen, ); }, onResume: (Map<String, dynamic> message) async { print('on resume $message'); String screen = message["screen"]; }, onLaunch: (Map<String, dynamic> message) async { print('on launch $message'); }, ); if (Platform.isIOS) iOS_Permission(); _firebaseMessaging.getToken().then((token){ print(token); }); }