i am trying to send push notification to my flutter app, Android part works fine, but iOS device is not receiving push notifications (I created APN Certificate, which works fine in my another app).
Here's my configurations
main.dart
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SharedPreferences prefs = await SharedPreferences.getInstance();
await Firebase.initializeApp();
String? logged =
prefs.getString('uid') == null || prefs.getString('uid') == ''
? null
: prefs.getString('uid');
initializeDateFormatting();
Intl.defaultLocale = 'tr';
listenChanges();
AwesomeNotifications().initialize(
// set the icon to null if you want to use the default app icon
'resource://drawable/res_app_icon',
[]);
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
// Create the initialization for your desired push service here
runApp(MyApp(
logged: logged,
));
}
class MyApp extends StatefulWidget {
MyApp({required this.logged});
String? logged;
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return GetMaterialApp(
debugShowCheckedModeBanner: false,
title: 'Greatr',
theme: whiteTheme,
home: widget.logged != null ? SplashScreen() : Onboarding(),
);
}
}
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
AwesomeNotifications().createNotificationFromJsonData(message.data);
}
It's the same as my working example.
AppDelegate.swift
import UIKit
import Flutter
import Firebase
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Also enabled Push Notifications and BackgroundModes(background fetch and remote notifications)
trying to solve this problem for 2-3 days and tried every solution, still no notification, any idea how to fix it?
Versions
awesome_notifications: ^0.0.6+10
firebase_core: "^1.0.4"
firebase_messaging: "^9.1.2"