Reputation: 890
After having only few problems to switch from OneSingal to Firebase for Push-Notifications I cannot get it to work on iOS. (Flutter (Channel stable, 3.10.6, on macOS 13.4 22F66 darwin-arm64, locale de-DE))
Here what I have done:
Flutter: Following the guide on: https://firebase.flutter.dev/docs/messaging/apple-integration/
Firebase-Console: Created iOS Project with correct APNs-Authentification-Key (double-checked)
X-Code: The Provisioning-Profile has Notifications enabled (double-checked) Bunla Identifier is Correct (double-checked) Team is Correct (double-checked) The Provisioning Profile is an Xcode Managed Profile Background modes: Background fetch and Remote Notifications are enabled Push-Notificatios are added
Code in Flutter Project:
library firebase_messaging;
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
class FirebaseMessaging {
Future<String?> initFirebaseAndGetToken() async {
await Firebase.initializeApp();
FirebaseMessaging messaging = FirebaseMessaging.instance;
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
if (settings.authorizationStatus == AuthorizationStatus.authorized) {
print('User granted permission');
} else if (settings.authorizationStatus == AuthorizationStatus.provisional) {
print('User granted provisional permission');
} else {
print('User declined or has not accepted permission');
}
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
if (message.notification != null) {
print('Message also contained a notification: ${message.notification}');
}
});
return messaging.getToken();
}
}
output: "User granted permission", token is available but when sending a push message via the firebase console it does not work (iPhone7 is connected to the Mac for debugging)
No errors in console when running the app (via IntelliJ Idea Ultimate).
How can I find out what the problem is or what should I check to find the problem?
Upvotes: 0
Views: 518
Reputation: 890
Problem was an Type Error in the apple teamid in the firebase console.
Upvotes: 0