Yes, from version 1.0.30
and up of the Pushy iOS SDK, you can disable AppDelegate method swizzling by calling the following method directly after initializing the Pushy
class:
// Disable AppDelegate method swizzling pushy.toggleMethodSwizzling(false)
For the SDK to continue working properly after disabling method swizzling, please override the following APNs methods in your AppDelegate implementation file, making sure to invoke the Pushy iOS SDK at the end of each of them, as follows:
Swift:
// APNs has assigned the device a unique token func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { // Call internal Pushy SDK method Pushy.shared?.application(application, didRegisterForRemoteNotificationsWithDeviceToken:deviceToken) } // APNs failed to register the device for push notifications func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { // Call internal Pushy SDK method Pushy.shared?.application(application, didFailToRegisterForRemoteNotificationsWithError:error) } // Device received notification (legacy callback) func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { // Call internal Pushy SDK method Pushy.shared?.application(application, didReceiveRemoteNotification:userInfo) } // Device received notification (with completion handler) func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { // Call internal Pushy SDK method Pushy.shared?.application(application, didReceiveRemoteNotification:userInfo, fetchCompletionHandler: completionHandler) }
Objective C:
// APNs has assigned the device a unique token
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Call internal Pushy SDK method [Pushy.shared application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; }
// APNs failed to register the device for push notifications - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
// Call internal Pushy SDK method [Pushy.shared application:application didFailToRegisterForRemoteNotificationsWithError:error]; }
// Device received notification (legacy callback) - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Call internal Pushy SDK method [Pushy.shared application:application didReceiveRemoteNotification:userInfo]; }
// Device received notification (with completion handler) - (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
// Call internal Pushy SDK method [Pushy.shared application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; }
Finally, please ensure you have disabled method swizzling in the other SDKs as well. For Firebase, please follow the instructions mentioned in the official Firebase docs.