Reputation: 31
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);
});
}
Upvotes: 3
Views: 5647
Reputation: 391
I know this is quite late, but I had the same issue.
My problem was that I didn't download the 'GoogleService-Info.plist' again after I added the Key to Firebase.
After downloading it again and adding it to the Xcode project, push notifications worked like a charm :)
Hope this helps
Upvotes: 0
Reputation: 5439
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:
Remote notifications
in Background Modes
under your Target
in Xcode?Let me know how this turns out for you :)
Upvotes: 2