When the Pushwoosh SDK shares an app with another push provider (Firebase, for example), both try to own UNUserNotificationCenterDelegate. Whichever one is assigned last wins, and Pushwoosh can never finish device registration — so the push token stays null and test pushes never arrive.
The fix is to register your other provider's delegate with Pushwoosh's delegate proxy instead of assigning it to UNUserNotificationCenter directly. The proxy fans every delegate callback out to all registered handlers, so both SDKs keep working.
Recommended API (iOS SDK 7.0 and newer)
import UIKit
import Pushwoosh
import UserNotifications
@main
class AppDelegate: UIResponder, UIApplicationDelegate, PWMessagingDelegate {
// Delegate instance for your OTHER push provider.
let otherPushDelegate = OtherPushProviderDelegate()
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Application code comes from Info.plist (Pushwoosh_APPID) or from
// Pushwoosh.initialize(withAppCode:). The applicationCode property
// itself is read-only.
Pushwoosh.initialize(withAppCode: "XXXXX-XXXXX")
Pushwoosh.configure.delegate = self
// ** SOLUTION ** register the other provider's delegate with the proxy
Pushwoosh.configure.addNotificationCenterDelegate(otherPushDelegate)
// Initialize your other provider, e.g. Firebase:
// FirebaseApp.configure()
// Messaging.messaging().delegate = otherPushDelegate
Pushwoosh.configure.registerForPushNotifications()
return true
}
}
class OtherPushProviderDelegate: NSObject, UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.banner, .sound, .badge])
}
}
On older SDKs
Before 7.0 the same thing is done through the proxy object directly:
Pushwoosh.sharedInstance().notificationCenterDelegateProxy?.add(otherPushDelegate)
Common mistakes:
- Assigning to
notificationCenterDelegateProxy— it is a read-onlyPWNotificationCenterDelegateProxy, not a slot for your delegate. - Setting
applicationCodeor anapiTokenproperty on the shared instance — neither is writable onPushwoosh. UsePushwoosh_APPIDinInfo.plistorPushwoosh.initialize(withAppCode:). - Setting
UNUserNotificationCenter.current().delegateyourself after Pushwoosh has initialized — that detaches the proxy and reintroduces the conflict.
Comments
0 comments
Please sign in to leave a comment.