[ad_1]
I attempted following the official firebase flutter dev information to arrange background and foreground notifications.
For testing i’ve tried sending messages/notifications from Firebase Console and my iphone machine efficiently obtained the notification 2 out of 8 instances. The 8 tries had been within the span of two hours.
Can anyone level in me in the suitable course to set this up? I think about it is my Flutter arrange inflicting the problem. On Firebase Console, all messages had been “Accomplished” standing.
My principal.dart file
void principal() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
FirebaseMessaging messaging = FirebaseMessaging.occasion;
runApp(const MyApp());
NotificationSettings settings = await messaging.requestPermission(
alert: true,
announcement: false,
badge: true,
carPlay: false,
criticalAlert: false,
provisional: false,
sound: true,
);
if (settings.authorizationStatus == AuthorizationStatus.approved) {
print('Person granted permission');
} else if (settings.authorizationStatus == AuthorizationStatus.provisional) {
print('Person granted provisional permission');
} else {
print('Person declined or has not accepted permission');
}
}
and my AppDelegate.swift file
import UIKit
import Flutter
import Firebase
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func utility(
_ utility: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
if #obtainable(iOS 10.0, *){
UNUserNotificationCenter.present().delegate = self
}
return tremendous.utility(utility, didFinishLaunchingWithOptions: launchOptions)
}
}
[ad_2]
