Closed EArminjon closed 3 years ago
Fixed with the following swift code :
import UIKit
import Firebase
import Flutter
import WonderPush
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
var flutter_native_splash = 1
UIApplication.shared.isStatusBarHidden = false
WonderPush.setClientId("the_secret_client_id", secret:"the_secret_secret")
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
//must be call after UNUSErNotificationCenter, else wonderpush is overrided
WonderPush.setupDelegateForUserNotificationCenter()
}
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return WonderPush.application(application, didFinishLaunchingWithOptions: launchOptions)
}
func application(_ application: UIApplication?, didReceive notification: UILocalNotification?) {
WonderPush.application(application, didReceive: notification)
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
WonderPush.application(application, didRegisterForRemoteNotificationsWithDeviceToken: deviceToken)
}
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
WonderPush.application(application, didFailToRegisterForRemoteNotificationsWithError: error)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [String : Any]) {
WonderPush.application(application, didReceiveRemoteNotification: userInfo)
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
WonderPush.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
}
func applicationDidEnterBackground(_ application: UIApplication) {
WonderPush.applicationDidEnterBackground(application)
}
func applicationDidBecomeActive(_ application: UIApplication) {
WonderPush.applicationDidBecomeActive(application)
}
func application(_ application: UIApplication?, didRegister notificationSettings: UIUserNotificationSettings?) {
WonderPush.application(application, didRegister: notificationSettings)
}
}
Hi,
I'm not sure what you mean by "the gesture". Is it a field on the UNNotificationResponse
that you were expecting? Our SDK does not touch such object. Source
So you basically removed the call to WonderPush.setupDelegateForApplication(application)
and forwarded the individual calls yourself. So the only difference I see is that this may be better compatible with any other framework that may affect the AppDelegate too.
Maybe the only change required can be the order of calls to WonderPush.setupDelegateForApplication(application)
and/or WonderPush.setupDelegateForUserNotificationCenter()
.
A simpler solution is to slightly change the WonderPush initialization in the AppDelegate:
place it later, in the application:didFinishLaunchingWithOptions:
method, right after GeneratedPluginRegistrant.register(with: self)
This change will make sure your handler is called on notification click.
I've updated our Flutter instructions to reflect this: https://docs.wonderpush.com/docs/flutter-push-notifications#step-2-prepare-your-xcode-project-for-push-notifications
Hi,
I would like to get some wonderpush notification from my backend and some scheduled ones from my app. I see a conflict, my local notification didn't work as expected. In fact, In my code, I set an action on notification click. It seems that, wonderpush redirect the notification to the right handler (User Notification Framework) but without the gesture. When clicking on my local notification, the app is launched but my callback inside is not called.
My environnement : Flutter (swift, kotlin) wonderpush_flutter 2.1.3 wonderpush_fcm_flutter 1.0.3 flutter_local_notifications 8.1.1+2 (User Notification Framework)
Bellow, logs:
Can you help me :) ?