pushwoosh-react-native-plugin 6.1.50 → 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/index.js +44 -1
- package/package.json +1 -1
- package/pushwoosh-react-native-plugin.podspec +3 -3
- package/src/android/build.gradle +1 -1
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPackage.java +1 -4
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/PushwooshPlugin.java +14 -1
- package/src/ios/PushwooshPlugin/Pushwoosh.h +5 -5
- package/src/ios/PushwooshPlugin/Pushwoosh.m +141 -1
- package/InlineInApp.js +0 -71
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/InlineInAppManager.java +0 -48
- package/src/android/src/main/java/com/pushwoosh/reactnativeplugin/RCTInlineInAppView.java +0 -75
- package/src/ios/PushwooshPlugin/PWInlineInAppManager.h +0 -17
- package/src/ios/PushwooshPlugin/PWInlineInAppManager.m +0 -54
package/index.js
CHANGED
|
@@ -4,6 +4,22 @@ import { NativeModules } from 'react-native';
|
|
|
4
4
|
|
|
5
5
|
const PushwooshModule = NativeModules.Pushwoosh;
|
|
6
6
|
|
|
7
|
+
//Constant: RichMediaStyle
|
|
8
|
+
//Rich Media presentation style constants.
|
|
9
|
+
//
|
|
10
|
+
//Values:
|
|
11
|
+
// MODAL - Rich Media displayed as modal dialog
|
|
12
|
+
// LEGACY - Rich Media displayed as full-screen activity
|
|
13
|
+
//
|
|
14
|
+
//Example:
|
|
15
|
+
//(start code)
|
|
16
|
+
// Pushwoosh.setRichMediaType(Pushwoosh.RichMediaStyle.MODAL);
|
|
17
|
+
//(end)
|
|
18
|
+
const RichMediaStyle = {
|
|
19
|
+
MODAL: 0,
|
|
20
|
+
LEGACY: 1
|
|
21
|
+
};
|
|
22
|
+
|
|
7
23
|
//Class: PushNotification
|
|
8
24
|
//Use `PushNotification` to register device for push notifications on Pushwoosh and customize notification appearance.
|
|
9
25
|
//
|
|
@@ -621,11 +637,38 @@ class PushNotification {
|
|
|
621
637
|
PushwooshModule.setLanguage(language);
|
|
622
638
|
}
|
|
623
639
|
|
|
624
|
-
// Enables Huawei push messaging
|
|
640
|
+
// Enables Huawei push messaging
|
|
625
641
|
enableHuaweiPushNotifications() {
|
|
626
642
|
PushwooshModule.enableHuaweiPushNotifications();
|
|
627
643
|
}
|
|
628
644
|
|
|
645
|
+
// Sets the Rich Media presentation style.
|
|
646
|
+
//
|
|
647
|
+
// Parameters:
|
|
648
|
+
// "type" - Rich Media style (Pushwoosh.RichMediaStyle.MODAL or Pushwoosh.RichMediaStyle.LEGACY)
|
|
649
|
+
//
|
|
650
|
+
// Example:
|
|
651
|
+
// Pushwoosh.setRichMediaType(Pushwoosh.RichMediaStyle.MODAL);
|
|
652
|
+
setRichMediaType(type: number) {
|
|
653
|
+
PushwooshModule.setRichMediaType(type);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Returns the current Rich Media presentation style.
|
|
657
|
+
//
|
|
658
|
+
// Parameters:
|
|
659
|
+
// "callback" - callback function that receives the current style (MODAL, LEGACY)
|
|
660
|
+
//
|
|
661
|
+
// Example:
|
|
662
|
+
// Pushwoosh.getRichMediaType((type) => {
|
|
663
|
+
// console.log("Rich Media Type: " + (type === Pushwoosh.RichMediaStyle.MODAL ? "MODAL" : "LEGACY"));
|
|
664
|
+
// });
|
|
665
|
+
getRichMediaType(callback: Function) {
|
|
666
|
+
PushwooshModule.getRichMediaType(callback);
|
|
667
|
+
}
|
|
668
|
+
|
|
629
669
|
}
|
|
630
670
|
|
|
671
|
+
// Export RichMediaStyle constants
|
|
672
|
+
PushNotification.prototype.RichMediaStyle = RichMediaStyle;
|
|
673
|
+
|
|
631
674
|
module.exports = new PushNotification();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
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'
|
|
7
7
|
s.license = 'MIT'
|
|
8
8
|
s.homepage = 'n/a'
|
|
9
9
|
s.source = { :git => "https://github.com/Pushwoosh/pushwoosh-react-native-plugin.git" }
|
|
10
|
-
s.source_files = 'src/ios/PushwooshPlugin/Pushwoosh.{h,m}', 'src/ios/PushwooshPlugin/PWEventDispatcher.{h,m}'
|
|
10
|
+
s.source_files = 'src/ios/PushwooshPlugin/Pushwoosh.{h,m}', 'src/ios/PushwooshPlugin/PWEventDispatcher.{h,m}'
|
|
11
11
|
s.platform = :ios, "11.0"
|
|
12
12
|
s.xcconfig = {
|
|
13
13
|
"HEADER_SEARCH_PATHS" => "${PODS_ROOT}/Headers/Public/React"
|
|
@@ -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
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
package com.pushwoosh.reactnativeplugin;
|
|
2
2
|
|
|
3
|
-
import android.view.ViewManager;
|
|
4
|
-
|
|
5
3
|
import com.facebook.react.ReactPackage;
|
|
6
4
|
import com.facebook.react.bridge.JavaScriptModule;
|
|
7
5
|
import com.facebook.react.bridge.NativeModule;
|
|
8
6
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
9
7
|
|
|
10
8
|
import java.util.ArrayList;
|
|
11
|
-
import java.util.Arrays;
|
|
12
9
|
import java.util.Collections;
|
|
13
10
|
import java.util.List;
|
|
14
11
|
|
|
@@ -20,7 +17,7 @@ public class PushwooshPackage implements ReactPackage {
|
|
|
20
17
|
|
|
21
18
|
@Override
|
|
22
19
|
public List<com.facebook.react.uimanager.ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
23
|
-
return
|
|
20
|
+
return Collections.emptyList();
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
@Override
|
|
@@ -43,6 +43,8 @@ import com.pushwoosh.notification.VibrateType;
|
|
|
43
43
|
import com.pushwoosh.tags.TagsBundle;
|
|
44
44
|
import com.pushwoosh.notification.LocalNotification;
|
|
45
45
|
import com.pushwoosh.notification.LocalNotificationReceiver;
|
|
46
|
+
import com.pushwoosh.richmedia.RichMediaManager;
|
|
47
|
+
import com.pushwoosh.richmedia.RichMediaType;
|
|
46
48
|
|
|
47
49
|
import org.json.JSONObject;
|
|
48
50
|
|
|
@@ -93,7 +95,6 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
|
|
|
93
95
|
return "Pushwoosh";
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
|
|
97
98
|
@ReactMethod
|
|
98
99
|
public void init(ReadableMap config, Callback success, Callback error) {
|
|
99
100
|
String appId = config.getString("pw_appid");
|
|
@@ -550,6 +551,18 @@ public class PushwooshPlugin extends ReactContextBaseJavaModule implements Lifec
|
|
|
550
551
|
Pushwoosh.getInstance().registerWhatsappNumber(phoneNumber);
|
|
551
552
|
}
|
|
552
553
|
|
|
554
|
+
@ReactMethod
|
|
555
|
+
public void setRichMediaType(int type) {
|
|
556
|
+
RichMediaType richMediaType = type == 0 ? RichMediaType.MODAL : RichMediaType.DEFAULT;
|
|
557
|
+
RichMediaManager.setRichMediaType(richMediaType);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
@ReactMethod
|
|
561
|
+
public void getRichMediaType(Callback callback) {
|
|
562
|
+
RichMediaType type = RichMediaManager.getRichMediaType();
|
|
563
|
+
callback.invoke(type.ordinal());
|
|
564
|
+
}
|
|
565
|
+
|
|
553
566
|
///
|
|
554
567
|
/// LifecycleEventListener callbacks
|
|
555
568
|
///
|
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
|
|
13
13
|
#if __has_include(<PushwooshFramework/PushNotificationManager.h>)
|
|
14
14
|
#import <PushwooshFramework/PushNotificationManager.h>
|
|
15
|
-
#import <PushwooshFramework/PWInAppManager.h>
|
|
16
|
-
#import <PushwooshInboxUI/PushwooshInboxUI.h>
|
|
17
|
-
#import <PushwooshFramework/PWInlineInAppView.h>
|
|
18
15
|
#import <PushwooshFramework/PWInbox.h>
|
|
16
|
+
#import <PushwooshCore/PWInAppManager.h>
|
|
17
|
+
#import <PushwooshCore/PWMedia.h>
|
|
18
|
+
#import <PushwooshInboxUI/PushwooshInboxUI.h>
|
|
19
19
|
#else
|
|
20
20
|
#import "PushNotificationManager.h"
|
|
21
|
+
#import "PWInbox.h"
|
|
21
22
|
#import "PWInAppManager.h"
|
|
23
|
+
#import "PWMedia.h"
|
|
22
24
|
#import "PushwooshInboxUI.h"
|
|
23
|
-
#import "PWInlineInAppView.h"
|
|
24
|
-
#import "PWInbox.h"
|
|
25
25
|
#endif
|
|
26
26
|
|
|
27
27
|
@interface PushwooshPlugin: RCTEventEmitter<RCTBridgeModule, PushNotificationDelegate>
|
|
@@ -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);
|
|
@@ -879,7 +907,21 @@ RCT_EXPORT_METHOD(registerSMSNumber:(NSString *)phoneNumber) {
|
|
|
879
907
|
RCT_EXPORT_METHOD(registerWhatsappNumber:(NSString *)phoneNumber) {
|
|
880
908
|
[[Pushwoosh sharedInstance] registerWhatsappNumber:phoneNumber];
|
|
881
909
|
}
|
|
882
|
-
|
|
910
|
+
|
|
911
|
+
RCT_EXPORT_METHOD(setRichMediaType:(nonnull NSNumber *)type) {
|
|
912
|
+
PWRichMediaPresentationStyle style = [type integerValue] == 0
|
|
913
|
+
? PWRichMediaPresentationStyleModal
|
|
914
|
+
: PWRichMediaPresentationStyleLegacy;
|
|
915
|
+
[Pushwoosh.media setRichMediaPresentationStyle:style];
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
RCT_EXPORT_METHOD(getRichMediaType:(RCTResponseSenderBlock)callback) {
|
|
919
|
+
PWRichMediaPresentationStyle style = [Pushwoosh.media richMediaPresentationStyle];
|
|
920
|
+
if (callback) {
|
|
921
|
+
callback(@[@(style)]);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
883
925
|
#pragma mark - PushNotificationDelegate
|
|
884
926
|
|
|
885
927
|
- (void)onDidRegisterForRemoteNotificationsWithDeviceToken:(NSString *)token {
|
|
@@ -925,11 +967,21 @@ RCT_EXPORT_METHOD(registerWhatsappNumber:(NSString *)phoneNumber) {
|
|
|
925
967
|
- (void)onPushReceived:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
926
968
|
if (onStart) {
|
|
927
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
|
+
}
|
|
928
975
|
}
|
|
929
976
|
}
|
|
930
977
|
- (void)onPushAccepted:(PushNotificationManager *)manager withNotification:(NSDictionary *)pushNotification onStart:(BOOL)onStart {
|
|
931
978
|
if (onStart) {
|
|
932
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
|
+
}
|
|
933
985
|
}
|
|
934
986
|
}
|
|
935
987
|
|
|
@@ -938,3 +990,91 @@ RCT_EXPORT_METHOD(registerWhatsappNumber:(NSString *)phoneNumber) {
|
|
|
938
990
|
}
|
|
939
991
|
|
|
940
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
|
package/InlineInApp.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import {requireNativeComponent} from 'react-native';
|
|
4
|
-
|
|
5
|
-
class InlineInAppView extends React.Component {
|
|
6
|
-
_onLoaded = (event) => {
|
|
7
|
-
if (!this.props.onLoaded) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// process raw event...
|
|
12
|
-
this.props.onLoaded(event.nativeEvent);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
_onClosed = (event) => {
|
|
16
|
-
if (!this.props.onClosed) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// process raw event...
|
|
21
|
-
this.props.onClosed(event.nativeEvent);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
_onSizeChanged = (event) => {
|
|
25
|
-
if (!this.props.onSizeChanged) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// process raw event...
|
|
30
|
-
this.props.onSizeChanged(event.nativeEvent);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
render() {
|
|
34
|
-
return (
|
|
35
|
-
<PWInlineInAppView
|
|
36
|
-
{...this.props}
|
|
37
|
-
onLoaded = {this._onLoaded}
|
|
38
|
-
onClosed = {this._onClosed}
|
|
39
|
-
onSizeChanged = {this._onSizeChanged}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
InlineInAppView.propTypes = {
|
|
46
|
-
/**
|
|
47
|
-
* Value of the identifier property must be equal to the
|
|
48
|
-
* identifier attribute value of the in-app message you've
|
|
49
|
-
* created in Pushwoosh Control Panel
|
|
50
|
-
*/
|
|
51
|
-
identifier: PropTypes.string,
|
|
52
|
-
/**
|
|
53
|
-
* This event is called to notify you that an inline in-app
|
|
54
|
-
* was loaded and has been added to the view
|
|
55
|
-
*/
|
|
56
|
-
onLoaded: PropTypes.func,
|
|
57
|
-
/**
|
|
58
|
-
* This event is called to notify you that an inline in-app
|
|
59
|
-
* view has been closed by the user
|
|
60
|
-
*/
|
|
61
|
-
onClosed: PropTypes.func,
|
|
62
|
-
/**
|
|
63
|
-
* This event is called to notify you that an inline in-app
|
|
64
|
-
* view size has been changed
|
|
65
|
-
*/
|
|
66
|
-
onSizeChanged: PropTypes.func,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
var PWInlineInAppView = requireNativeComponent('PWInlineInAppView', InlineInAppView)
|
|
70
|
-
|
|
71
|
-
export default InlineInAppView
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
package com.pushwoosh.reactnativeplugin;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.common.MapBuilder;
|
|
4
|
-
import com.facebook.react.uimanager.SimpleViewManager;
|
|
5
|
-
import com.facebook.react.uimanager.ThemedReactContext;
|
|
6
|
-
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
7
|
-
|
|
8
|
-
import java.util.Map;
|
|
9
|
-
|
|
10
|
-
public class InlineInAppManager extends SimpleViewManager<RCTInlineInAppView> {
|
|
11
|
-
public static final String REACT_CLASS = "PWInlineInAppView";
|
|
12
|
-
|
|
13
|
-
@Override
|
|
14
|
-
public String getName() {
|
|
15
|
-
return REACT_CLASS;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Override
|
|
19
|
-
public RCTInlineInAppView createViewInstance(ThemedReactContext context) {
|
|
20
|
-
RCTInlineInAppView view = new RCTInlineInAppView(context);
|
|
21
|
-
return view;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@ReactProp(name = "identifier")
|
|
25
|
-
public void setIdentifier(final RCTInlineInAppView view, String identifier) {
|
|
26
|
-
view.setIdentifier(identifier);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public Map getExportedCustomBubblingEventTypeConstants() {
|
|
30
|
-
return MapBuilder.builder()
|
|
31
|
-
.put(
|
|
32
|
-
"onLoaded",
|
|
33
|
-
MapBuilder.of(
|
|
34
|
-
"phasedRegistrationNames",
|
|
35
|
-
MapBuilder.of("bubbled", "onLoaded")))
|
|
36
|
-
.put(
|
|
37
|
-
"onClosed",
|
|
38
|
-
MapBuilder.of(
|
|
39
|
-
"phasedRegistrationNames",
|
|
40
|
-
MapBuilder.of("bubbled", "onClosed")))
|
|
41
|
-
.put(
|
|
42
|
-
"onSizeChanged",
|
|
43
|
-
MapBuilder.of(
|
|
44
|
-
"phasedRegistrationNames",
|
|
45
|
-
MapBuilder.of("bubbled", "onSizeChanged")))
|
|
46
|
-
.build();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
package com.pushwoosh.reactnativeplugin;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.view.Choreographer;
|
|
5
|
-
import android.view.View;
|
|
6
|
-
|
|
7
|
-
import com.facebook.react.bridge.Arguments;
|
|
8
|
-
import com.facebook.react.bridge.ReactContext;
|
|
9
|
-
import com.facebook.react.bridge.WritableMap;
|
|
10
|
-
import com.facebook.react.uimanager.events.RCTEventEmitter;
|
|
11
|
-
import com.pushwoosh.inapp.view.inline.InlineInAppView;
|
|
12
|
-
import com.pushwoosh.inapp.view.inline.InlineInAppViewListener;
|
|
13
|
-
|
|
14
|
-
public class RCTInlineInAppView extends InlineInAppView implements InlineInAppViewListener {
|
|
15
|
-
public RCTInlineInAppView(Context context) {
|
|
16
|
-
super(context);
|
|
17
|
-
this.addInlineInAppViewListener(this);
|
|
18
|
-
setupLayoutHack();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
void setupLayoutHack() {
|
|
22
|
-
Choreographer.getInstance().postFrameCallback(new Choreographer.FrameCallback() {
|
|
23
|
-
@Override
|
|
24
|
-
public void doFrame(long frameTimeNanos) {
|
|
25
|
-
manuallyLayoutChildren();
|
|
26
|
-
getViewTreeObserver().dispatchOnGlobalLayout();
|
|
27
|
-
Choreographer.getInstance().postFrameCallback(this);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
void manuallyLayoutChildren() {
|
|
34
|
-
for (int i = 0; i < getChildCount(); i++) {
|
|
35
|
-
View child = getChildAt(i);
|
|
36
|
-
child.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
|
|
37
|
-
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
|
38
|
-
child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@Override
|
|
43
|
-
public void onInlineInAppLoaded() {
|
|
44
|
-
WritableMap event = Arguments.createMap();
|
|
45
|
-
event.putString("identifier", this.getIdentifier());
|
|
46
|
-
ReactContext reactContext = (ReactContext)getContext();
|
|
47
|
-
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
48
|
-
getId(),
|
|
49
|
-
"onLoaded",
|
|
50
|
-
event);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
@Override
|
|
54
|
-
public void onInlineInAppViewClosed() {
|
|
55
|
-
WritableMap event = Arguments.createMap();
|
|
56
|
-
event.putString("identifier", this.getIdentifier());
|
|
57
|
-
ReactContext reactContext = (ReactContext)getContext();
|
|
58
|
-
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
59
|
-
getId(),
|
|
60
|
-
"onClosed",
|
|
61
|
-
event);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@Override
|
|
65
|
-
public void onInlineInAppViewChangedSize(int var1, int var2) {
|
|
66
|
-
WritableMap event = Arguments.createMap();
|
|
67
|
-
event.putString("width", String.valueOf(var1));
|
|
68
|
-
event.putString("height", String.valueOf(var2));
|
|
69
|
-
ReactContext reactContext = (ReactContext)getContext();
|
|
70
|
-
reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
|
|
71
|
-
getId(),
|
|
72
|
-
"onSizeChanged",
|
|
73
|
-
event);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PWInlineInAppManager.h
|
|
3
|
-
// pushwoosh-react-native-plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Fectum on 15/01/2020.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "RCTViewManager.h"
|
|
9
|
-
#import "Pushwoosh.h"
|
|
10
|
-
|
|
11
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
12
|
-
|
|
13
|
-
@interface PWInlineInAppManager : RCTViewManager <PWInlineInAppViewDelegate>
|
|
14
|
-
|
|
15
|
-
@end
|
|
16
|
-
|
|
17
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PWInlineInAppManager.m
|
|
3
|
-
// pushwoosh-react-native-plugin
|
|
4
|
-
//
|
|
5
|
-
// Created by Fectum on 15/01/2020.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
#import "PWInlineInAppManager.h"
|
|
9
|
-
|
|
10
|
-
@interface PWReactInlineInAppView: PWInlineInAppView
|
|
11
|
-
|
|
12
|
-
@property (nonatomic) RCTBubblingEventBlock onLoaded;
|
|
13
|
-
@property (nonatomic) RCTBubblingEventBlock onClosed;
|
|
14
|
-
@property (nonatomic) RCTBubblingEventBlock onSizeChanged;
|
|
15
|
-
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
@implementation PWReactInlineInAppView
|
|
19
|
-
@end
|
|
20
|
-
|
|
21
|
-
@implementation PWInlineInAppManager
|
|
22
|
-
|
|
23
|
-
RCT_EXPORT_MODULE(PWInlineInAppView)
|
|
24
|
-
|
|
25
|
-
- (UIView *)view {
|
|
26
|
-
PWReactInlineInAppView *view = [PWReactInlineInAppView new];
|
|
27
|
-
view.delegate = self;
|
|
28
|
-
return view;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
RCT_EXPORT_VIEW_PROPERTY(identifier, NSString)
|
|
32
|
-
RCT_EXPORT_VIEW_PROPERTY(onLoaded, RCTBubblingEventBlock)
|
|
33
|
-
RCT_EXPORT_VIEW_PROPERTY(onClosed, RCTBubblingEventBlock)
|
|
34
|
-
RCT_EXPORT_VIEW_PROPERTY(onSizeChanged, RCTBubblingEventBlock)
|
|
35
|
-
|
|
36
|
-
- (void)inlineInAppDidLoadInView:(PWReactInlineInAppView *)inAppView {
|
|
37
|
-
if (inAppView.onLoaded) {
|
|
38
|
-
inAppView.onLoaded(@{@"identifier": inAppView.identifier});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
- (void)didCloseInlineInAppView:(PWReactInlineInAppView *)inAppView {
|
|
43
|
-
if (inAppView.onClosed) {
|
|
44
|
-
inAppView.onClosed(@{@"identifier": inAppView.identifier});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
- (void)didChangeSizeOfInlineInAppView:(PWReactInlineInAppView *)inAppView {
|
|
49
|
-
if (inAppView.onSizeChanged) {
|
|
50
|
-
inAppView.onSizeChanged(@{@"width": @(inAppView.bounds.size.width), @"height": @(inAppView.bounds.size.height)});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@end
|