If onPushReceived and onPushAccepted fire on Android but not on iOS, the usual cause is that your iOS AppDelegate intercepts the notification callbacks and does not forward them on.
First: check whether you override the callbacks at all
In a stock Flutter project no native iOS code is required. On initialisation the Pushwoosh Flutter plugin installs itself as the UNUserNotificationCenter delegate, unless the current delegate is a FlutterAppDelegate (which conforms to FlutterAppLifeCycleProvider). In that case the plugin relies on FlutterAppDelegate forwarding the callbacks to registered plugins.
This means that if you have added your own userNotificationCenter(_:didReceive:withCompletionHandler:) or userNotificationCenter(_:willPresent:withCompletionHandler:) to AppDelegate.swift and did not call super, you have cut the forwarding chain and Pushwoosh never sees the notification. Removing your override, or adding the super call, usually resolves the problem on its own.
If you must keep a custom override
Always call through to super, and hand the payload to Pushwoosh explicitly. Note that the two callbacks cover different situations:
willPresentfires when a notification arrives while the app is in the foreground — this is what drivesonPushReceived.didReceivefires when the user taps a notification — this is what drivesonPushAccepted.
Overriding only didReceive will never restore onPushReceived.
import PushwooshFramework
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
Pushwoosh.sharedInstance().handlePushReceived(notification.request.content.userInfo)
super.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
}
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
Pushwoosh.sharedInstance().handlePushReceived(response.notification.request.content.userInfo)
super.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
}
Also verify
- The listeners are attached immediately after SDK initialisation at app start-up, before any notification can arrive.
- The Push Notifications capability and, for background delivery, the Remote notifications background mode are enabled in Xcode.
Pushwoosh_APPIDandPushwoosh_API_TOKENare present inInfo.plist.
Comments
0 comments
Please sign in to leave a comment.