Use case: When clicking on notification in iOS, app opens and I should be able to read payload data so that I can perform various actions upon opening the app like re-route, etc.
For this use case I have followed iOS notification setup provided by WebEngage.
This includes
calbacks for ios - https://docs.webengage.com/docs/flutter-callbacks#for-ios
disable swizzling - https://docs.webengage.com/docs/ios-advanced#7-disable-swizzling
my info.plist has -
<key>WEGLicenseCode</key> <string>xxxxx</string> <key>WEGLogLevel</key> <string>VERBOSE</string> <key>WEGEnvironment</key> <string>xx</string> <key>WEGManualIntegration</key> <true/>
appdelegate.swift file -
import UIKit
import Flutter
import flutter_local_notifications
import WebEngage
import webengage_flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
var bridge:WebEngagePlugin? = nil
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
var bridge = WebEngagePlugin()
// for push notif payload fetch callback
WebEngage.sharedInstance().pushNotificationDelegate = self.bridge
// init weg sdk
WebEngage.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
}
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
extension AppDelegate: UNUserNotificationCenterDelegate {
@available(iOS 10.0, *)
override func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
print("center: ", center, "\nnotification: ", notification)
WEGManualIntegration.userNotificationCenter(center, willPresent: notification)
//Handle any other services messages with method swizzling disabled
// example : firebase
//Messaging.messaging().appDidReceiveMessage(userInfo)
completionHandler([.alert, .badge, .sound])
}
@available(iOS 10.0, *)
override func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
print("center: ", center, " response: ", response)
WEGManualIntegration.userNotificationCenter(center, didReceive: response)
//Handle any other services messages with method swizzling disabled
// example : firebase
//Messaging.messaging().appDidReceiveMessage(userInfo)
completionHandler()
}
}
but upon trying to build in simulator i get -
Swift Compiler Error (Xcode): Redundant conformance of 'AppDelegate' to protocol 'UNUserNotificationCenterDelegate'
/path/project_name/ios/Runner/AppDelegate.swift:33:23
Could not build the application for the simulator.
Error launching application on iPhone 14 Pro Max.
Use case: When clicking on notification in iOS, app opens and I should be able to read payload data so that I can perform various actions upon opening the app like re-route, etc.
For this use case I have followed iOS notification setup provided by WebEngage.
This includes
calbacks for ios - https://docs.webengage.com/docs/flutter-callbacks#for-ios
disable swizzling - https://docs.webengage.com/docs/ios-advanced#7-disable-swizzling
my info.plist has -
<key>WEGLicenseCode</key> <string>xxxxx</string> <key>WEGLogLevel</key> <string>VERBOSE</string> <key>WEGEnvironment</key> <string>xx</string> <key>WEGManualIntegration</key> <true/>appdelegate.swift file -
but upon trying to build in simulator i get -