pushwoosh-react-native-plugin 6.1.51 → 6.1.52
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = "pushwoosh-react-native-plugin"
|
|
3
|
-
s.version = "6.1.
|
|
3
|
+
s.version = "6.1.52"
|
|
4
4
|
s.summary = "React Native Pushwoosh Push Notifications module"
|
|
5
5
|
s.requires_arc = true
|
|
6
6
|
s.author = 'Pushwoosh'
|
|
@@ -15,6 +15,6 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.static_framework = true
|
|
16
16
|
|
|
17
17
|
s.dependency 'React'
|
|
18
|
-
s.dependency 'PushwooshXCFramework', '7.0.
|
|
18
|
+
s.dependency 'PushwooshXCFramework', '7.0.21'
|
|
19
19
|
s.dependency 'PushwooshInboxUIXCFramework'
|
|
20
20
|
end
|
package/src/android/build.gradle
CHANGED
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
#import "PWEventDispatcher.h"
|
|
12
12
|
#import <React/RCTEventDispatcher.h>
|
|
13
13
|
#import <React/RCTConvert.h>
|
|
14
|
+
#import <React/RCTLinkingManager.h>
|
|
14
15
|
|
|
15
16
|
#import <UserNotifications/UserNotifications.h>
|
|
16
17
|
#import <PushwooshFramework/PushNotificationManager.h>
|
|
17
18
|
|
|
18
19
|
#import <objc/runtime.h>
|
|
20
|
+
#import <objc/message.h>
|
|
19
21
|
|
|
20
22
|
#define kPushwooshPluginImplementationInfoPlistKey @"Pushwoosh_PLUGIN_NOTIFICATION_HANDLER"
|
|
21
23
|
|
|
@@ -32,6 +34,7 @@ static id objectOrNull(id object) {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
static NSDictionary * gStartPushData = nil;
|
|
37
|
+
static NSURL * gPushDeepLinkURL = nil; // Deep link URL for New Architecture support
|
|
35
38
|
static NSString * const kRegistrationSuccesEvent = @"PWRegistrationSuccess";
|
|
36
39
|
static NSString * const kRegistrationErrorEvent = @"PWRegistrationError";
|
|
37
40
|
static NSString * const kPushReceivedEvent = @"PWPushReceived";
|
|
@@ -48,6 +51,31 @@ static NSString * const kPushReceivedJSEvent = @"pushReceived";
|
|
|
48
51
|
|
|
49
52
|
@end
|
|
50
53
|
|
|
54
|
+
@interface RCTLinkingManager (PushwooshSwizzle)
|
|
55
|
+
- (void)pwplugin_original_getInitialURL:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject;
|
|
56
|
+
@end
|
|
57
|
+
|
|
58
|
+
// Swizzled getInitialURL for RCTLinkingManager (New Architecture support)
|
|
59
|
+
static void pwplugin_getInitialURL(id self, SEL _cmd, RCTPromiseResolveBlock resolve, RCTPromiseRejectBlock reject) {
|
|
60
|
+
// If we have a saved deep link URL from push notification, return it
|
|
61
|
+
if (gPushDeepLinkURL) {
|
|
62
|
+
NSURL *url = gPushDeepLinkURL;
|
|
63
|
+
gPushDeepLinkURL = nil; // Clear after use (one-time)
|
|
64
|
+
resolve(url.absoluteString);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Otherwise call the original implementation
|
|
69
|
+
SEL originalSelector = @selector(pwplugin_original_getInitialURL:reject:);
|
|
70
|
+
if ([self respondsToSelector:originalSelector]) {
|
|
71
|
+
void (*originalIMP)(id, SEL, RCTPromiseResolveBlock, RCTPromiseRejectBlock);
|
|
72
|
+
originalIMP = (void (*)(id, SEL, RCTPromiseResolveBlock, RCTPromiseRejectBlock))objc_msgSend;
|
|
73
|
+
originalIMP(self, originalSelector, resolve, reject);
|
|
74
|
+
} else {
|
|
75
|
+
resolve([NSNull null]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
51
79
|
void pushwoosh_swizzle(Class class, SEL fromChange, SEL toChange, IMP impl, const char * signature) {
|
|
52
80
|
Method method = nil;
|
|
53
81
|
method = class_getInstanceMethod(class, fromChange);
|
|
@@ -939,11 +967,21 @@ RCT_EXPORT_METHOD(getRichMediaType:(RCTResponseSenderBlock)callback) {
|
|
|
939
967
|
- (void)onPushReceived:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
940
968
|
if (onStart) {
|
|
941
969
|
gStartPushData = pushNotification;
|
|
970
|
+
// Save deep link URL for New Architecture (Linking.getInitialURL support)
|
|
971
|
+
NSString *link = pushNotification[@"l"];
|
|
972
|
+
if (link) {
|
|
973
|
+
gPushDeepLinkURL = [NSURL URLWithString:link];
|
|
974
|
+
}
|
|
942
975
|
}
|
|
943
976
|
}
|
|
944
977
|
- (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
945
978
|
if (onStart) {
|
|
946
979
|
gStartPushData = pushNotification;
|
|
980
|
+
// Save deep link URL for New Architecture (Linking.getInitialURL support)
|
|
981
|
+
NSString *link = pushNotification[@"l"];
|
|
982
|
+
if (link) {
|
|
983
|
+
gPushDeepLinkURL = [NSURL URLWithString:link];
|
|
984
|
+
}
|
|
947
985
|
}
|
|
948
986
|
}
|
|
949
987
|
|
|
@@ -952,3 +990,91 @@ RCT_EXPORT_METHOD(getRichMediaType:(RCTResponseSenderBlock)callback) {
|
|
|
952
990
|
}
|
|
953
991
|
|
|
954
992
|
@end
|
|
993
|
+
|
|
994
|
+
#pragma mark - RCTLinkingManager Swizzle for New Architecture
|
|
995
|
+
|
|
996
|
+
// Temporary delegate to capture push notification on cold start before React Native initializes
|
|
997
|
+
API_AVAILABLE(ios(10.0))
|
|
998
|
+
@interface PWEarlyNotificationDelegate : NSObject <UNUserNotificationCenterDelegate>
|
|
999
|
+
@property (nonatomic, weak) id<UNUserNotificationCenterDelegate> originalDelegate;
|
|
1000
|
+
@end
|
|
1001
|
+
|
|
1002
|
+
@implementation PWEarlyNotificationDelegate
|
|
1003
|
+
|
|
1004
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
1005
|
+
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
1006
|
+
withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)) {
|
|
1007
|
+
// Capture deep link from push notification on cold start
|
|
1008
|
+
if ([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
|
1009
|
+
NSDictionary *userInfo = response.notification.request.content.userInfo;
|
|
1010
|
+
NSString *link = userInfo[@"l"];
|
|
1011
|
+
if (link) {
|
|
1012
|
+
gPushDeepLinkURL = [NSURL URLWithString:link];
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// Forward to original delegate
|
|
1017
|
+
if (self.originalDelegate && [self.originalDelegate respondsToSelector:@selector(userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:)]) {
|
|
1018
|
+
[self.originalDelegate userNotificationCenter:center didReceiveNotificationResponse:response withCompletionHandler:completionHandler];
|
|
1019
|
+
} else {
|
|
1020
|
+
completionHandler();
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
1025
|
+
willPresentNotification:(UNNotification *)notification
|
|
1026
|
+
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(ios(10.0)) {
|
|
1027
|
+
// Forward to original delegate
|
|
1028
|
+
if (self.originalDelegate && [self.originalDelegate respondsToSelector:@selector(userNotificationCenter:willPresentNotification:withCompletionHandler:)]) {
|
|
1029
|
+
[self.originalDelegate userNotificationCenter:center willPresentNotification:notification withCompletionHandler:completionHandler];
|
|
1030
|
+
} else {
|
|
1031
|
+
completionHandler(UNNotificationPresentationOptionNone);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
@end
|
|
1036
|
+
|
|
1037
|
+
static PWEarlyNotificationDelegate *gEarlyDelegate = nil;
|
|
1038
|
+
|
|
1039
|
+
@implementation RCTLinkingManager (PushwooshDeepLink)
|
|
1040
|
+
|
|
1041
|
+
+ (void)load {
|
|
1042
|
+
static dispatch_once_t onceToken;
|
|
1043
|
+
dispatch_once(&onceToken, ^{
|
|
1044
|
+
// Swizzle getInitialURL:reject: to support deep links from push on New Architecture
|
|
1045
|
+
pushwoosh_swizzle(
|
|
1046
|
+
[RCTLinkingManager class],
|
|
1047
|
+
@selector(getInitialURL:reject:),
|
|
1048
|
+
@selector(pwplugin_original_getInitialURL:reject:),
|
|
1049
|
+
(IMP)pwplugin_getInitialURL,
|
|
1050
|
+
"v@:@@"
|
|
1051
|
+
);
|
|
1052
|
+
|
|
1053
|
+
// Set up early notification delegate to capture push on cold start
|
|
1054
|
+
if (@available(iOS 10.0, *)) {
|
|
1055
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
1056
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
1057
|
+
gEarlyDelegate = [[PWEarlyNotificationDelegate alloc] init];
|
|
1058
|
+
gEarlyDelegate.originalDelegate = center.delegate;
|
|
1059
|
+
center.delegate = gEarlyDelegate;
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Also check launchOptions when app finishes launching
|
|
1064
|
+
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification
|
|
1065
|
+
object:nil
|
|
1066
|
+
queue:nil
|
|
1067
|
+
usingBlock:^(NSNotification *notification) {
|
|
1068
|
+
NSDictionary *launchOptions = notification.userInfo;
|
|
1069
|
+
NSDictionary *remoteNotification = launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey];
|
|
1070
|
+
if (remoteNotification) {
|
|
1071
|
+
NSString *link = remoteNotification[@"l"];
|
|
1072
|
+
if (link && !gPushDeepLinkURL) {
|
|
1073
|
+
gPushDeepLinkURL = [NSURL URLWithString:link];
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}];
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
@end
|