react-native-push-signal 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/PushSignalCenter.m +8 -33
- package/package.json +1 -1
package/ios/PushSignalCenter.m
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#import "PushSignalCenter.h"
|
|
2
2
|
#import "PushSignalLaunchStore.h"
|
|
3
|
-
#import <
|
|
3
|
+
#import <objc/runtime.h>
|
|
4
4
|
#import <UIKit/UIKit.h>
|
|
5
5
|
|
|
6
6
|
@interface PushSignalAppDelegateHook : NSObject
|
|
@@ -550,45 +550,20 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
|
550
550
|
- (void)pushSignal_application:(UIApplication *)application
|
|
551
551
|
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
552
552
|
[[PushSignalCenter shared] handleDeviceToken:deviceToken];
|
|
553
|
-
|
|
553
|
+
// After swizzle, this selector holds the original AppDelegate implementation (if any).
|
|
554
|
+
SEL original = @selector(pushSignal_application:didRegisterForRemoteNotificationsWithDeviceToken:);
|
|
555
|
+
if ([self respondsToSelector:original]) {
|
|
556
|
+
[self pushSignal_application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
|
557
|
+
}
|
|
554
558
|
}
|
|
555
559
|
|
|
556
560
|
- (void)pushSignal_application:(UIApplication *)application
|
|
557
561
|
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
|
|
558
562
|
[[PushSignalCenter shared] handleRegistrationError:error];
|
|
559
|
-
[self pushSignal_forwardError:application error:error];
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
- (void)pushSignal_forwardDeviceToken:(UIApplication *)application deviceToken:(NSData *)deviceToken {
|
|
563
|
-
SEL hooked = @selector(application:didRegisterForRemoteNotificationsWithDeviceToken:);
|
|
564
|
-
SEL original = @selector(pushSignal_application:didRegisterForRemoteNotificationsWithDeviceToken:);
|
|
565
|
-
if (![self respondsToSelector:original]) {
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
Class cls = object_getClass(self);
|
|
569
|
-
IMP originalImp = class_getMethodImplementation(cls, original);
|
|
570
|
-
IMP hookedImp = class_getMethodImplementation(cls, hooked);
|
|
571
|
-
if (originalImp == NULL || originalImp == hookedImp) {
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
void (*fn)(id, SEL, UIApplication *, NSData *) = (void (*)(id, SEL, UIApplication *, NSData *))originalImp;
|
|
575
|
-
fn(self, original, application, deviceToken);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
- (void)pushSignal_forwardError:(UIApplication *)application error:(NSError *)error {
|
|
579
|
-
SEL hooked = @selector(application:didFailToRegisterForRemoteNotificationsWithError:);
|
|
580
563
|
SEL original = @selector(pushSignal_application:didFailToRegisterForRemoteNotificationsWithError:);
|
|
581
|
-
if (
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
Class cls = object_getClass(self);
|
|
585
|
-
IMP originalImp = class_getMethodImplementation(cls, original);
|
|
586
|
-
IMP hookedImp = class_getMethodImplementation(cls, hooked);
|
|
587
|
-
if (originalImp == NULL || originalImp == hookedImp) {
|
|
588
|
-
return;
|
|
564
|
+
if ([self respondsToSelector:original]) {
|
|
565
|
+
[self pushSignal_application:application didFailToRegisterForRemoteNotificationsWithError:error];
|
|
589
566
|
}
|
|
590
|
-
void (*fn)(id, SEL, UIApplication *, NSError *) = (void (*)(id, SEL, UIApplication *, NSError *))originalImp;
|
|
591
|
-
fn(self, original, application, error);
|
|
592
567
|
}
|
|
593
568
|
|
|
594
569
|
@end
|