Question: I implemented a Pushwoosh push delegate in my AppDelegate. The device token callback fires, but my "push received" and "push opened" callbacks are never called.
Answer: The PushNotificationManager / PushNotificationDelegate pair used in older integration guides is legacy. In the current Pushwoosh iOS SDK (7.x) push events are delivered through PWMessagingDelegate, and the SDK registers itself as the UNUserNotificationCenter delegate for you — you no longer need to assign notificationCenterDelegate manually, and the if (@available(iOS 10.0, *)) guard can be removed (the SDK requires iOS 11.0 or newer, and most optional modules require iOS 13.0+).
A minimal correct setup looks like this:
import PushwooshFramework
class AppDelegate: UIResponder, UIApplicationDelegate, PWMessagingDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Pushwoosh.sharedInstance().delegate = self
Pushwoosh.sharedInstance().registerForPushNotifications()
return true
}
func pushwoosh(_ pushwoosh: Pushwoosh, onMessageReceived message: PWMessage) {
// push arrived
}
func pushwoosh(_ pushwoosh: Pushwoosh, onMessageOpened message: PWMessage) {
// user tapped the push
}
}
If the callbacks still do not fire, check the following:
- The delegate is assigned before
registerForPushNotifications()is called. - The object you assign to
Pushwoosh.sharedInstance().delegateis retained (a local variable will be released and the callbacks will silently stop). - Your app does not overwrite
UNUserNotificationCenter.current().delegateafter the Pushwoosh SDK is initialized — if another SDK takes over the notification center delegate, Pushwoosh stops receiving the events. - Push received events are only reported while the app is running; a push delivered to a terminated app produces only the "opened" event when the user taps it.
For the exact, up-to-date method signatures see the iOS SDK reference: PushwooshFramework documentation.
Comments
0 comments
Please sign in to leave a comment.