diff --git a/Framework/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h b/Framework/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h index 500d7a15..dc6574a5 100644 --- a/Framework/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h +++ b/Framework/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h @@ -18,7 +18,7 @@ #endif -#define PUSHWOOSH_VERSION @"6.5.4" +#define PUSHWOOSH_VERSION @"6.5.5" @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy; diff --git a/Framework/Pushwoosh.framework/Versions/A/Pushwoosh b/Framework/Pushwoosh.framework/Versions/A/Pushwoosh index 4c10763c..a045960c 100644 Binary files a/Framework/Pushwoosh.framework/Versions/A/Pushwoosh and b/Framework/Pushwoosh.framework/Versions/A/Pushwoosh differ diff --git a/Framework/PushwooshGeozones.framework/Versions/A/PushwooshGeozones b/Framework/PushwooshGeozones.framework/Versions/A/PushwooshGeozones index 651f1be2..9edc371b 100644 Binary files a/Framework/PushwooshGeozones.framework/Versions/A/PushwooshGeozones and b/Framework/PushwooshGeozones.framework/Versions/A/PushwooshGeozones differ diff --git a/XCFramework/Pushwoosh.xcframework/Info.plist b/XCFramework/Pushwoosh.xcframework/Info.plist index e2eac322..11b16dca 100644 --- a/XCFramework/Pushwoosh.xcframework/Info.plist +++ b/XCFramework/Pushwoosh.xcframework/Info.plist @@ -6,47 +6,47 @@ LibraryIdentifier - ios-arm64_i386_x86_64-simulator + ios-arm64_x86_64-maccatalyst LibraryPath Pushwoosh.framework SupportedArchitectures arm64 - i386 x86_64 SupportedPlatform ios SupportedPlatformVariant - simulator + maccatalyst LibraryIdentifier - ios-arm64_armv7 + ios-arm64_i386_x86_64-simulator LibraryPath Pushwoosh.framework SupportedArchitectures arm64 - armv7 + i386 + x86_64 SupportedPlatform ios + SupportedPlatformVariant + simulator LibraryIdentifier - ios-arm64_x86_64-maccatalyst + ios-arm64_armv7 LibraryPath Pushwoosh.framework SupportedArchitectures arm64 - x86_64 + armv7 SupportedPlatform ios - SupportedPlatformVariant - maccatalyst CFBundlePackageType diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Headers/Pushwoosh.h b/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Headers/Pushwoosh.h index 500d7a15..dc6574a5 100644 --- a/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Headers/Pushwoosh.h +++ b/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Headers/Pushwoosh.h @@ -18,7 +18,7 @@ #endif -#define PUSHWOOSH_VERSION @"6.5.4" +#define PUSHWOOSH_VERSION @"6.5.5" @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy; diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Pushwoosh b/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Pushwoosh index 57469394..6586af93 100755 Binary files a/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Pushwoosh and b/XCFramework/Pushwoosh.xcframework/ios-arm64_armv7/Pushwoosh.framework/Pushwoosh differ diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Headers/Pushwoosh.h b/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Headers/Pushwoosh.h index 500d7a15..dc6574a5 100644 --- a/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Headers/Pushwoosh.h +++ b/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Headers/Pushwoosh.h @@ -18,7 +18,7 @@ #endif -#define PUSHWOOSH_VERSION @"6.5.4" +#define PUSHWOOSH_VERSION @"6.5.5" @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy; diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Pushwoosh b/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Pushwoosh index c82174a8..0d4cfd01 100755 Binary files a/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Pushwoosh and b/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/Pushwoosh differ diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/_CodeSignature/CodeResources b/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/_CodeSignature/CodeResources index 5e93aef2..33e183b6 100644 --- a/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/_CodeSignature/CodeResources +++ b/XCFramework/Pushwoosh.xcframework/ios-arm64_i386_x86_64-simulator/Pushwoosh.framework/_CodeSignature/CodeResources @@ -50,7 +50,7 @@ Headers/Pushwoosh.h - /TKTVA/9pE+I9nel0kCiC0uH55o= + Rqo/ztLLr9zoJF4SI8EBQlvsi64= Info.plist @@ -188,11 +188,11 @@ hash - /TKTVA/9pE+I9nel0kCiC0uH55o= + Rqo/ztLLr9zoJF4SI8EBQlvsi64= hash2 - 2CgB553dZ2+NMrvMorn3RwYaPEgIPO9h6Zc/UWLdjak= + u1MZ4EWQnx80JLX914bhORZA2nFUJqlra89gFVxhSso= Modules/module.modulemap diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h b/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h index 500d7a15..dc6574a5 100644 --- a/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h +++ b/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Headers/Pushwoosh.h @@ -18,7 +18,7 @@ #endif -#define PUSHWOOSH_VERSION @"6.5.4" +#define PUSHWOOSH_VERSION @"6.5.5" @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy; diff --git a/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Pushwoosh b/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Pushwoosh index 62cefae2..f30c80dd 100755 Binary files a/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Pushwoosh and b/XCFramework/Pushwoosh.xcframework/ios-arm64_x86_64-maccatalyst/Pushwoosh.framework/Versions/A/Pushwoosh differ diff --git a/XCFramework/PushwooshGeozones.xcframework/Info.plist b/XCFramework/PushwooshGeozones.xcframework/Info.plist index 8c32fc35..4efdcb76 100644 --- a/XCFramework/PushwooshGeozones.xcframework/Info.plist +++ b/XCFramework/PushwooshGeozones.xcframework/Info.plist @@ -6,47 +6,47 @@ LibraryIdentifier - ios-arm64_i386_x86_64-simulator + ios-arm64_x86_64-maccatalyst LibraryPath PushwooshGeozones.framework SupportedArchitectures arm64 - i386 x86_64 SupportedPlatform ios SupportedPlatformVariant - simulator + maccatalyst LibraryIdentifier - ios-arm64_x86_64-maccatalyst + ios-arm64_armv7 LibraryPath PushwooshGeozones.framework SupportedArchitectures arm64 - x86_64 + armv7 SupportedPlatform ios - SupportedPlatformVariant - maccatalyst LibraryIdentifier - ios-arm64_armv7 + ios-arm64_i386_x86_64-simulator LibraryPath PushwooshGeozones.framework SupportedArchitectures arm64 - armv7 + i386 + x86_64 SupportedPlatform ios + SupportedPlatformVariant + simulator CFBundlePackageType diff --git a/iOS_SDK/Pushwoosh/Pushwoosh.podspec b/iOS_SDK/Pushwoosh/Pushwoosh.podspec index 199961c5..56b95d74 100644 --- a/iOS_SDK/Pushwoosh/Pushwoosh.podspec +++ b/iOS_SDK/Pushwoosh/Pushwoosh.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |s| s.name = "Pushwoosh" - s.version = "6.5.4" + s.version = "6.5.5" s.summary = "Push notifications library by Pushwoosh." s.platform = :ios diff --git a/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.h b/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.h index b9543b2d..65bf0454 100644 --- a/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.h +++ b/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.h @@ -20,6 +20,8 @@ FOUNDATION_EXPORT NSString * const defaultApplicationClosedEvent; + (instancetype)sharedManager; +- (void)startTracking; + @end NS_ASSUME_NONNULL_END diff --git a/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.m b/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.m index aa4756dd..151d8544 100644 --- a/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.m +++ b/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWAppLifecycleTrackingManager/PWAppLifecycleTrackingManager.m @@ -15,10 +15,6 @@ #import "PWUtils.h" #import "PWServerCommunicationManager.h" -//RMA events -static NSString * const kApplicationOpenedEvent = @"_ApplicationOpened"; -static NSString * const kApplicationClosedEvent = @"_ApplicationClosed"; - NSString * const defaultApplicationOpenedEvent = @"PW_ApplicationOpen"; NSString * const defaultApplicationClosedEvent = @"PW_ApplicationMinimized"; @@ -36,10 +32,6 @@ @implementation PWAppLifecycleTrackingManager { id _communicationStartedHandler; } -+ (void)load { - [[self sharedManager] startTracking]; -} - + (instancetype)sharedManager { static dispatch_once_t once; static id sharedInstance; @@ -76,11 +68,6 @@ - (void)startSendingEvents { _appInForeground = YES; - //send inital event - if (NSClassFromString(@"PWRateMyAppManager")) { - [self sendAppOpenEvent]; - } - if (_defaultAppOpenAllowed == YES) { [self sendDefaultEvent: defaultApplicationOpenedEvent]; _initialDefaultOpenEventSent = YES; @@ -132,22 +119,12 @@ - (void)sendAppOpen { [[Pushwoosh sharedInstance].dataManager sendAppOpenWithCompletion:nil]; }); - if (NSClassFromString(@"PWRateMyAppManager")) { - [self sendAppOpenEvent]; - } - if (_defaultAppOpenAllowed == YES) { [self sendDefaultEvent: defaultApplicationOpenedEvent]; } } } -- (void)sendAppOpenEvent { - if (UIApplication.sharedApplication.applicationState != UIApplicationStateBackground) { - [[PWInAppManager sharedManager] postEvent:kApplicationOpenedEvent withAttributes:nil completion:nil]; - } -} - - (void)sendDefaultEvent: (NSString *) event{ NSDictionary *attrs = @{ @"device_type": @1, @@ -158,18 +135,12 @@ - (void)sendDefaultEvent: (NSString *) event{ - (void)onApplicationClosed { _appInForeground = NO; - if (NSClassFromString(@"PWRateMyAppManager")) { - [self sendAppClosedEvent]; - } + if (_defaultAppClosedAllowed == YES) { [self sendDefaultEvent: defaultApplicationClosedEvent]; } } -- (void)sendAppClosedEvent { - [[PWInAppManager sharedManager] postEvent:kApplicationClosedEvent withAttributes:nil completion:nil]; -} - - (void)setDefaultAppOpenAllowed:(BOOL)defaultAppOpenAllowed { _defaultAppOpenAllowed = defaultAppOpenAllowed; diff --git a/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWScreenTrackingManager/PWScreenTrackingManager.m b/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWScreenTrackingManager/PWScreenTrackingManager.m index a1bf499b..7e6bc50c 100644 --- a/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWScreenTrackingManager/PWScreenTrackingManager.m +++ b/iOS_SDK/Pushwoosh/Pushwoosh/Data/Automation/Embedded Events/PWScreenTrackingManager/PWScreenTrackingManager.m @@ -26,12 +26,6 @@ @interface PWScreenTrackingManager () @implementation PWScreenTrackingManager -+ (void)load { - if (NSClassFromString(@"PWRateMyAppManager")) { - [[self sharedManager] startTracking]; - } -} - + (instancetype)sharedManager { static dispatch_once_t once; static id sharedInstance; @@ -64,10 +58,6 @@ void _replacement_viewDidAppear(UIViewController * self, SEL _cmd, BOOL animated dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kScreenOpenedEventDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ @try { - if (NSClassFromString(@"PWRateMyAppManager")) { - [[PWInAppManager sharedManager] postEvent:kScreenOpenedEvent withAttributes:nil]; - } - if ([PWScreenTrackingManager sharedManager].defaultScreenOpenAllowed) { NSString *screenName = self.title.length > 0 ? self.title : self.navigationItem.title; diff --git a/iOS_SDK/Pushwoosh/Pushwoosh/Public/Pushwoosh.h b/iOS_SDK/Pushwoosh/Pushwoosh/Public/Pushwoosh.h index 500d7a15..dc6574a5 100644 --- a/iOS_SDK/Pushwoosh/Pushwoosh/Public/Pushwoosh.h +++ b/iOS_SDK/Pushwoosh/Pushwoosh/Public/Pushwoosh.h @@ -18,7 +18,7 @@ #endif -#define PUSHWOOSH_VERSION @"6.5.4" +#define PUSHWOOSH_VERSION @"6.5.5" @class Pushwoosh, PWMessage, PWNotificationCenterDelegateProxy; diff --git a/iOS_SDK/Pushwoosh/Pushwoosh/Utils/Runtime/PWPushRuntime.ios.m b/iOS_SDK/Pushwoosh/Pushwoosh/Utils/Runtime/PWPushRuntime.ios.m index 1c16820d..6101834d 100644 --- a/iOS_SDK/Pushwoosh/Pushwoosh/Utils/Runtime/PWPushRuntime.ios.m +++ b/iOS_SDK/Pushwoosh/Pushwoosh/Utils/Runtime/PWPushRuntime.ios.m @@ -15,6 +15,7 @@ #import "PWUtils.h" #import "PWPlatformModule.h" #import "PWNotificationManagerCompat.h" +#import "PWAppLifecycleTrackingManager.h" #if !__has_feature(objc_arc) #error "ARC is required to compile Pushwoosh SDK" @@ -23,13 +24,14 @@ static IMP pw_original_setApplicationIconBadgeNumber_Imp; static IMP pw_original_registerForRemoteNotifications_Imp; static IMP pw_original_didReceiveRemoteNotification_Imp; +static IMP pw_original_didRegisterForRemoteNotificationWithDeviceToken_Imp; +static IMP pw_original_didFailToRegisterForRemoteNotificationsWithError_Imp; +static IMP pw_original_didReceiveRemoteNotificationWithUserInfo_Imp; +static IMP pw_original_didFinishLaunchingWithOptionsExtension; +static IMP pw_original_didFinishLaunchingWithOptions; @interface UIApplication (PushwooshRuntime) -- (void)application:(UIApplication *)application pw_didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken; -- (void)application:(UIApplication *)application pw_didFailToRegisterForRemoteNotificationsWithError:(NSError *)err; -- (void)application:(UIApplication *)application pw_didReceiveRemoteNotification:(NSDictionary *)userInfo; -- (BOOL)application:(UIApplication *)application pw_didFinishLaunchingWithOptions:(NSDictionary *)launchOptions; - (BOOL)application:(UIApplication *)application pw_openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; - (BOOL)application:(UIApplication *)application pw_openURL:(NSURL *)url options:(NSDictionary *)options; - (BOOL)application:(UIApplication *)application pw_handleOpenURL:(NSURL *)url; @@ -60,67 +62,49 @@ BOOL dynamicDidFinishLaunchingAutoTest(id self, SEL _cmd, id application, id lau return [self application:application pw_didFinishLaunchingWithOptionsAutoTest:launchOptions]; } -BOOL dynamicDidFinishLaunching(id self, SEL _cmd, id application, id launchOptions) { - BOOL result = YES; - - if ([self respondsToSelector:@selector(application:pw_didFinishLaunchingWithOptions:)]) { - result = (BOOL)[self application:application pw_didFinishLaunchingWithOptions:launchOptions]; - } else { - [self applicationDidFinishLaunching:application]; - result = YES; - } - - if (![[PWPreferences preferences] hasAppCode]) { - // pushwoosh has not been initialized yet - return result; - } - - if (![PushNotificationManager pushManager].delegate) { - if ([[UIApplication sharedApplication] respondsToSelector:@selector(getPushwooshDelegate)]) { - [PushNotificationManager pushManager].delegate = [[UIApplication sharedApplication] getPushwooshDelegate]; - } else { - [PushNotificationManager pushManager].delegate = (NSObject *)self; - } - } - - if (![UNUserNotificationCenter currentNotificationCenter].delegate) { - //this function will also handle UIApplicationLaunchOptionsLocationKey - [[PushNotificationManager pushManager] handlePushReceived:launchOptions]; +BOOL _replacement_didFinishLaunchingWithOptionsExtensionRequest(id self, SEL _cmd, UIApplication *application, NSDictionary *launchOptions) { + ((BOOL(*)(id, SEL, UIApplication *, NSDictionary *))pw_original_didFinishLaunchingWithOptionsExtension)(self, _cmd, application, launchOptions); + + BOOL result = YES; + BOOL useRuntime = [PWConfig config].useRuntime; + + [[PWAppLifecycleTrackingManager sharedManager] startTracking]; + + if ([[UIApplication sharedApplication] respondsToSelector:@selector(pushwooshUseRuntimeMagic)] && useRuntime) { + if (launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey]) { + NSLog(@"Application was launched from a remote notification"); + } + + if (![[PWPreferences preferences] hasAppCode]) { + // pushwoosh has not been initialized yet + return result; + } + + if (![PushNotificationManager pushManager].delegate) { + if ([[UIApplication sharedApplication] respondsToSelector:@selector(getPushwooshDelegate)]) { + [PushNotificationManager pushManager].delegate = [[UIApplication sharedApplication] getPushwooshDelegate]; + } else { + [PushNotificationManager pushManager].delegate = (NSObject *)self; + } + } + + if (![UNUserNotificationCenter currentNotificationCenter].delegate) { + //this function will also handle UIApplicationLaunchOptionsLocationKey + [[PushNotificationManager pushManager] handlePushReceived:launchOptions]; + } } - - return result; -} - -void dynamicDidRegisterForRemoteNotificationsWithDeviceToken(id self, SEL _cmd, id application, id devToken) { - if ([self respondsToSelector:@selector(application:pw_didRegisterForRemoteNotificationsWithDeviceToken:)]) { - [self application:application pw_didRegisterForRemoteNotificationsWithDeviceToken:devToken]; - } - if ([[PWPreferences preferences] hasAppCode]) { - [[PushNotificationManager pushManager] handlePushRegistration:devToken]; - } + return result; } -void dynamicDidFailToRegisterForRemoteNotificationsWithError(id self, SEL _cmd, id application, id error) { - if ([self respondsToSelector:@selector(application:pw_didFailToRegisterForRemoteNotificationsWithError:)]) { - [self application:application pw_didFailToRegisterForRemoteNotificationsWithError:error]; - } - - PWLogError(@"Error registering for push notifications. Error: %@", error); - - if ([[PWPreferences preferences] hasAppCode]) { - [[PushNotificationManager pushManager] handlePushRegistrationFailure:error]; - } -} - -void dynamicDidReceiveRemoteNotification(id self, SEL _cmd, id application, id userInfo) { - if ([self respondsToSelector:@selector(application:pw_didReceiveRemoteNotification:)]) { - [self application:application pw_didReceiveRemoteNotification:userInfo]; - } - - if ([[PWPreferences preferences] hasAppCode]) { - [[PushNotificationManager pushManager] handlePushReceived:userInfo]; - } +void _replacement_didReceiveRemoteNotificationWithUserInfo(id self, SEL _cmd, UIApplication *application, NSDictionary *userInfo) { + if ([self respondsToSelector:@selector(application:didReceiveRemoteNotification:)]) { + ((void(*)(id, SEL, UIApplication *, NSDictionary *))pw_original_didReceiveRemoteNotificationWithUserInfo_Imp)(self, _cmd, application, userInfo); + } + + if ([[PWPreferences preferences] hasAppCode]) { + [[PushNotificationManager pushManager] handlePushReceived:userInfo]; + } } void _replacement_didReceiveRemoteNotification(id self, SEL _cmd, UIApplication * application, NSDictionary * userInfo, void (^completionHandler)(UIBackgroundFetchResult)) { @@ -244,7 +228,7 @@ - (void)pw_swizzleOpenURLMethods:(Class)delegateClass { - (void)performSwizzlingForDelegate:(id)delegate proxy:(id)proxy { BOOL useRuntime = [PWConfig config].useRuntime; - + if (delegate.superclass == NSProxy.class) { @try { NSString *propertyName = @"delegates"; @@ -281,6 +265,8 @@ - (void)performSwizzlingForDelegate:(id)delegate proxy:(i } } + [self swizzle_didFinishLaunchingWithOptionsForExtensionRequest:[delegate class]]; + //override runtime functions only if requested (used in plugins or by user decision) if (![[UIApplication sharedApplication] respondsToSelector:@selector(pushwooshUseRuntimeMagic)] && !useRuntime) { //auto test check @@ -310,30 +296,9 @@ - (void)performSwizzlingForDelegate:(id)delegate proxy:(i Class delegateClass = [delegate class]; - [PWUtils swizzle:delegateClass - fromSelector:@selector(application:didFinishLaunchingWithOptions:) - toSelector:@selector(application:pw_didFinishLaunchingWithOptions:) - implementation:(IMP)dynamicDidFinishLaunching - typeEncoding:"v@:::"]; - - [PWUtils swizzle:delegateClass - fromSelector:@selector(application:didRegisterForRemoteNotificationsWithDeviceToken:) - toSelector:@selector(application:pw_didRegisterForRemoteNotificationsWithDeviceToken:) - implementation:(IMP)dynamicDidRegisterForRemoteNotificationsWithDeviceToken - typeEncoding:"v@:::"]; - - [PWUtils swizzle:delegateClass - fromSelector:@selector(application:didFailToRegisterForRemoteNotificationsWithError:) - toSelector:@selector(application:pw_didFailToRegisterForRemoteNotificationsWithError:) - implementation:(IMP)dynamicDidFailToRegisterForRemoteNotificationsWithError - typeEncoding:"v@:::"]; - - [PWUtils swizzle:delegateClass - fromSelector:@selector(application:didReceiveRemoteNotification:) - toSelector:@selector(application:pw_didReceiveRemoteNotification:) - implementation:(IMP)dynamicDidReceiveRemoteNotification - typeEncoding:"v@:::"]; - + [self swizzle_didRegisterForRemoteNotificationsWithDeviceToken:delegateClass]; + [self swizzle_didFailToRegisterForRemoteNotificationsWithError:delegateClass]; + [self swizzle_didReceiveRemoteNotification:delegateClass]; [self swizzle_didReceiveRemoteNotificationWithFetchBlock:delegateClass]; [self pw_swizzleOpenURLMethods:delegateClass]; @@ -350,15 +315,52 @@ - (void)performSwizzlingForDelegate:(id)delegate proxy:(i [self pw_setDelegate:proxy ? : delegate]; } +- (void)swizzle_didFinishLaunchingWithOptionsForExtensionRequest:(Class)delegateClass { + static BOOL swizzleDone = NO; + if (swizzleDone) + return; + swizzleDone = YES; + + Method originalMethod = class_getInstanceMethod(delegateClass, @selector(application:didFinishLaunchingWithOptions:)); + pw_original_didFinishLaunchingWithOptionsExtension = method_setImplementation(originalMethod, (IMP)_replacement_didFinishLaunchingWithOptionsExtensionRequest); +} + - (void)swizzle_didReceiveRemoteNotificationWithFetchBlock:(Class)delegateClass { Method originalMethod = class_getInstanceMethod(delegateClass, @selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)); pw_original_didReceiveRemoteNotification_Imp = method_setImplementation(originalMethod, (IMP)_replacement_didReceiveRemoteNotification); } +- (void)swizzle_didReceiveRemoteNotification:(Class)delegeteClass { + Method originalMethod = class_getInstanceMethod(delegeteClass, @selector(application:didReceiveRemoteNotification:)); + pw_original_didReceiveRemoteNotificationWithUserInfo_Imp = method_setImplementation(originalMethod, (IMP)_replacement_didReceiveRemoteNotificationWithUserInfo); +} + - (void)pw_setDelegate:(id)delegate { [self performSwizzlingForDelegate:delegate proxy:nil]; } +void _replacement_didRegisterForRemoteNotificationWithToken(id self, SEL _cmd, UIApplication *application, NSData *deviceToken) { + if ([self respondsToSelector:@selector(application:didRegisterForRemoteNotificationsWithDeviceToken:)]) { + ((void(*)(id, SEL, UIApplication*, NSData*))pw_original_didRegisterForRemoteNotificationWithDeviceToken_Imp)(self, _cmd, application, deviceToken); + } + + if ([[PWPreferences preferences] hasAppCode]) { + [[PushNotificationManager pushManager] handlePushRegistration:deviceToken]; + } +} + +void _replacement_didFailToRegisterForRemoteNotificationsWithError(id self, SEL _cmd, UIApplication *application, NSError *error) { + if ([self respondsToSelector:@selector(application:didFailToRegisterForRemoteNotificationsWithError:)]) { + ((void(*)(id, SEL, UIApplication*, NSError*))pw_original_didFailToRegisterForRemoteNotificationsWithError_Imp)(self, _cmd, application, error); + } + + PWLogError(@"Error registering for push notifications. Error: %@", error); + + if ([[PWPreferences preferences] hasAppCode]) { + [[PushNotificationManager pushManager] handlePushRegistrationFailure:error]; + } +} + void _replacement_setApplicationIconBadgeNumber(UIApplication * self, SEL _cmd, NSInteger badgeNumber) { ((void(*)(id,SEL,NSInteger))pw_original_setApplicationIconBadgeNumber_Imp)(self, _cmd, badgeNumber); @@ -384,6 +386,16 @@ + (void)load { } } +- (void)swizzle_didRegisterForRemoteNotificationsWithDeviceToken:(Class)delegateClass { + Method originalMethod = class_getInstanceMethod(delegateClass, @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:)); + pw_original_didRegisterForRemoteNotificationWithDeviceToken_Imp = method_setImplementation(originalMethod, (IMP)_replacement_didRegisterForRemoteNotificationWithToken); +} + +- (void)swizzle_didFailToRegisterForRemoteNotificationsWithError:(Class)delegateClass { + Method originalMethod = class_getInstanceMethod(delegateClass, @selector(application:didFailToRegisterForRemoteNotificationsWithError:)); + pw_original_didFailToRegisterForRemoteNotificationsWithError_Imp = method_setImplementation(originalMethod, (IMP)_replacement_didFailToRegisterForRemoteNotificationsWithError); +} + + (void)swizzle_setApplicationIconBadgeNumber { Method originalMethod = class_getInstanceMethod([UIApplication class], @selector(setApplicationIconBadgeNumber:)); pw_original_setApplicationIconBadgeNumber_Imp = method_setImplementation(originalMethod, (IMP)_replacement_setApplicationIconBadgeNumber); diff --git a/iOS_SDK/Pushwoosh/PushwooshXCFramework.podspec b/iOS_SDK/Pushwoosh/PushwooshXCFramework.podspec index ac3a8ecb..cc586aa0 100644 --- a/iOS_SDK/Pushwoosh/PushwooshXCFramework.podspec +++ b/iOS_SDK/Pushwoosh/PushwooshXCFramework.podspec @@ -5,7 +5,7 @@ Pod::Spec.new do |s| s.name = "PushwooshXCFramework" - s.version = "6.5.4" + s.version = "6.5.5" s.summary = "Push notifications library by Pushwoosh." s.platform = :ios diff --git a/iOS_SDK/Pushwoosh/build/XCBuildData/build.db b/iOS_SDK/Pushwoosh/build/XCBuildData/build.db index 2abd575a..d2d93355 100644 Binary files a/iOS_SDK/Pushwoosh/build/XCBuildData/build.db and b/iOS_SDK/Pushwoosh/build/XCBuildData/build.db differ diff --git a/iOS_SDK/Pushwoosh/buildI/XCBuildData/7d204fb94c98a5faec65106c28ce8c76-desc.xcbuild b/iOS_SDK/Pushwoosh/buildI/XCBuildData/7d204fb94c98a5faec65106c28ce8c76-desc.xcbuild index ca5d7050..b784d504 100644 Binary files a/iOS_SDK/Pushwoosh/buildI/XCBuildData/7d204fb94c98a5faec65106c28ce8c76-desc.xcbuild and b/iOS_SDK/Pushwoosh/buildI/XCBuildData/7d204fb94c98a5faec65106c28ce8c76-desc.xcbuild differ diff --git a/iOS_SDK/Pushwoosh/buildI/XCBuildData/build.db b/iOS_SDK/Pushwoosh/buildI/XCBuildData/build.db index 943cf89e..12adc269 100644 Binary files a/iOS_SDK/Pushwoosh/buildI/XCBuildData/build.db and b/iOS_SDK/Pushwoosh/buildI/XCBuildData/build.db differ diff --git a/iOS_SDK/Pushwoosh/buildI/XCBuildData/ce0d156d282619b34a976188828ed341-desc.xcbuild b/iOS_SDK/Pushwoosh/buildI/XCBuildData/ce0d156d282619b34a976188828ed341-desc.xcbuild index 47309e9e..28e60522 100644 Binary files a/iOS_SDK/Pushwoosh/buildI/XCBuildData/ce0d156d282619b34a976188828ed341-desc.xcbuild and b/iOS_SDK/Pushwoosh/buildI/XCBuildData/ce0d156d282619b34a976188828ed341-desc.xcbuild differ