我最近遇到了一个关于freshchat和firebaseMessaging(FCM)的问题。当我发送带有深度链接的推送通知时,我的fcm代码(onMessageOpenedApp)在我仅使用iOS点击通知时没有被触发。没有看到任何关于这个问题的问题,我张贴以防万一的解决方案,为人民谁有这个问题在未来我希望这对你有用😊
l7wslrjt1#
freshchat库重载了原生ios函数(userNotificationCenter),我们只是添加了对父构造函数的调用超级用户通知中心(中心,将呈现:将显示,带有完成处理程序:使用完成处理程序)下面的代码(AppDelegate.swift)
import Flutter import Firebase import UserNotifications @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { FirebaseApp.configure() GeneratedPluginRegistrant.register(with: self) let viewController = UIApplication.shared.windows.first!.rootViewController as! UIViewController window = FreshchatSdkPluginWindow(frame: UIScreen.main.bounds) window.rootViewController = viewController UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in } UIApplication.shared.registerForRemoteNotifications() return super.application(application, didFinishLaunchingWithOptions: launchOptions) } override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { FreshchatSdkPlugin().setPushRegistrationToken(deviceToken) } //@available(iOS 10.0, *) override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent: UNNotification, withCompletionHandler: @escaping (UNNotificationPresentationOptions)->()) { let freshchatSdkPlugin = FreshchatSdkPlugin() if freshchatSdkPlugin.isFreshchatNotification(willPresent.request.content.userInfo) { freshchatSdkPlugin.handlePushNotification(willPresent.request.content.userInfo) } else { super.userNotificationCenter(center, willPresent: willPresent, withCompletionHandler: withCompletionHandler) } } //@available(iOS 10.0, *) override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive: UNNotificationResponse, withCompletionHandler: @escaping ()->()) { let freshchatSdkPlugin = FreshchatSdkPlugin() if freshchatSdkPlugin.isFreshchatNotification(didReceive.notification.request.content.userInfo) { freshchatSdkPlugin.handlePushNotification(didReceive.notification.request.content.userInfo) //Handled for freshchat notifications withCompletionHandler() } else { super.userNotificationCenter(center, didReceive: didReceive, withCompletionHandler: withCompletionHandler) } } }```
1条答案
按热度按时间l7wslrjt1#
freshchat库重载了原生ios函数(userNotificationCenter),我们只是添加了对父构造函数的调用
超级用户通知中心(中心,将呈现:将显示,带有完成处理程序:使用完成处理程序)
下面的代码(AppDelegate.swift)