@customerglu/react-native-customerglu 3.0.0-beta-1.0 → 3.0.0-beta-1.2

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.
Files changed (32) hide show
  1. package/ReactNativeCustomerglu.podspec +6 -1
  2. package/android/generated/java/com/customerglu/reactnativecustomerglu/NativeReactNativeCustomergluSpec.java +2 -2
  3. package/android/generated/jni/CMakeLists.txt +5 -5
  4. package/android/generated/jni/{RNReactNativeCustomergluSpec-generated.cpp → RNCustomergluSpec-generated.cpp} +3 -3
  5. package/android/generated/jni/{RNReactNativeCustomergluSpec.h → RNCustomergluSpec.h} +1 -1
  6. package/android/generated/jni/react/renderer/components/{RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpecJSI-generated.cpp → RNCustomergluSpec/RNCustomergluSpecJSI-generated.cpp} +2 -2
  7. package/{ios/generated/RNReactNativeCustomergluSpecJSI.h → android/generated/jni/react/renderer/components/RNCustomergluSpec/RNCustomergluSpecJSI.h} +6 -6
  8. package/ios/IosBannerView.h +16 -0
  9. package/ios/IosBannerView.mm +126 -0
  10. package/ios/IosBannerViewManager.mm +24 -0
  11. package/ios/ReactNativeCustomerglu-Bridging-Header.h +19 -0
  12. package/ios/Rncustomerglu.h +5 -2
  13. package/ios/Rncustomerglu.mm +487 -6
  14. package/ios/generated/{RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpec-generated.mm → RNCustomergluSpec/RNCustomergluSpec-generated.mm} +1 -1
  15. package/ios/generated/{RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpec.h → RNCustomergluSpec/RNCustomergluSpec.h} +6 -6
  16. package/ios/generated/{RNReactNativeCustomergluSpecJSI-generated.cpp → RNCustomergluSpecJSI-generated.cpp} +2 -2
  17. package/{android/generated/jni/react/renderer/components/RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpecJSI.h → ios/generated/RNCustomergluSpecJSI.h} +6 -6
  18. package/lib/commonjs/index.js +4 -4
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/index.js +4 -4
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/typescript/commonjs/src/NativeReactNativeCustomerglu.d.ts +2 -2
  23. package/lib/typescript/commonjs/src/NativeReactNativeCustomerglu.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/index.d.ts +2 -2
  25. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  26. package/lib/typescript/module/src/NativeReactNativeCustomerglu.d.ts +2 -2
  27. package/lib/typescript/module/src/NativeReactNativeCustomerglu.d.ts.map +1 -1
  28. package/lib/typescript/module/src/index.d.ts +2 -2
  29. package/lib/typescript/module/src/index.d.ts.map +1 -1
  30. package/package.json +4 -4
  31. package/src/NativeReactNativeCustomerglu.ts +2 -2
  32. package/src/index.tsx +9 -5
@@ -14,8 +14,12 @@ Pod::Spec.new do |s|
14
14
  s.platforms = { :ios => min_ios_version_supported }
15
15
  s.source = { :git => "https://github.com/customerglu/CG-SDK-React-Native.git", :tag => "#{s.version}" }
16
16
 
17
- s.source_files = "ios/**/*.{h,m,mm,cpp}"
17
+ s.swift_version = '5.0'
18
+
19
+
20
+ s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
18
21
  s.private_header_files = "ios/generated/**/*.h"
22
+ s.dependency "CustomerGlu", "3.0.12"
19
23
 
20
24
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21
25
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
@@ -32,6 +36,7 @@ Pod::Spec.new do |s|
32
36
  "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
33
37
  "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
34
38
  }
39
+ s.dependency "React-RCTFabric"
35
40
  s.dependency "React-Codegen"
36
41
  s.dependency "RCT-Folly"
37
42
  s.dependency "RCTRequired"
@@ -68,7 +68,7 @@ public abstract class NativeReactNativeCustomergluSpec extends ReactContextBaseJ
68
68
 
69
69
  @ReactMethod
70
70
  @DoNotStrip
71
- public abstract void loadCampaignById(String id, @Nullable ReadableMap obj);
71
+ public abstract void loadCampaignById(String campid, @Nullable ReadableMap obj);
72
72
 
73
73
  @ReactMethod
74
74
  @DoNotStrip
@@ -92,7 +92,7 @@ public abstract class NativeReactNativeCustomergluSpec extends ReactContextBaseJ
92
92
 
93
93
  @ReactMethod
94
94
  @DoNotStrip
95
- public abstract void isFcmApn(boolean id);
95
+ public abstract void isFcmApn(String value);
96
96
 
97
97
  @ReactMethod
98
98
  @DoNotStrip
@@ -6,18 +6,18 @@
6
6
  cmake_minimum_required(VERSION 3.13)
7
7
  set(CMAKE_VERBOSE_MAKEFILE on)
8
8
 
9
- file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNReactNativeCustomergluSpec/*.cpp)
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNCustomergluSpec/*.cpp)
10
10
 
11
11
  add_library(
12
- react_codegen_RNReactNativeCustomergluSpec
12
+ react_codegen_RNCustomergluSpec
13
13
  OBJECT
14
14
  ${react_codegen_SRCS}
15
15
  )
16
16
 
17
- target_include_directories(react_codegen_RNReactNativeCustomergluSpec PUBLIC . react/renderer/components/RNReactNativeCustomergluSpec)
17
+ target_include_directories(react_codegen_RNCustomergluSpec PUBLIC . react/renderer/components/RNCustomergluSpec)
18
18
 
19
19
  target_link_libraries(
20
- react_codegen_RNReactNativeCustomergluSpec
20
+ react_codegen_RNCustomergluSpec
21
21
  fbjni
22
22
  jsi
23
23
  # We need to link different libraries based on whether we are building rncore or not, that's necessary
@@ -26,7 +26,7 @@ target_link_libraries(
26
26
  )
27
27
 
28
28
  target_compile_options(
29
- react_codegen_RNReactNativeCustomergluSpec
29
+ react_codegen_RNCustomergluSpec
30
30
  PRIVATE
31
31
  -DLOG_TAG=\"ReactNative\"
32
32
  -fexceptions
@@ -8,7 +8,7 @@
8
8
  * @generated by codegen project: GenerateModuleJniCpp.js
9
9
  */
10
10
 
11
- #include "RNReactNativeCustomergluSpec.h"
11
+ #include "RNCustomergluSpec.h"
12
12
 
13
13
  namespace facebook::react {
14
14
 
@@ -84,7 +84,7 @@ static facebook::jsi::Value __hostFunction_NativeReactNativeCustomergluSpecJSI_e
84
84
 
85
85
  static facebook::jsi::Value __hostFunction_NativeReactNativeCustomergluSpecJSI_isFcmApn(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
86
86
  static jmethodID cachedMethodId = nullptr;
87
- return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "isFcmApn", "(Z)V", args, count, cachedMethodId);
87
+ return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, VoidKind, "isFcmApn", "(Ljava/lang/String;)V", args, count, cachedMethodId);
88
88
  }
89
89
 
90
90
  static facebook::jsi::Value __hostFunction_NativeReactNativeCustomergluSpecJSI_UpdateProfile(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
@@ -178,7 +178,7 @@ NativeReactNativeCustomergluSpecJSI::NativeReactNativeCustomergluSpecJSI(const J
178
178
  methodMap_["getCampaignStatus"] = MethodMetadata {2, __hostFunction_NativeReactNativeCustomergluSpecJSI_getCampaignStatus};
179
179
  }
180
180
 
181
- std::shared_ptr<TurboModule> RNReactNativeCustomergluSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
181
+ std::shared_ptr<TurboModule> RNCustomergluSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
182
182
  if (moduleName == "Rncustomerglu") {
183
183
  return std::make_shared<NativeReactNativeCustomergluSpecJSI>(params);
184
184
  }
@@ -26,6 +26,6 @@ public:
26
26
 
27
27
 
28
28
  JSI_EXPORT
29
- std::shared_ptr<TurboModule> RNReactNativeCustomergluSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
29
+ std::shared_ptr<TurboModule> RNCustomergluSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
30
 
31
31
  } // namespace facebook::react
@@ -7,7 +7,7 @@
7
7
  * @generated by codegen project: GenerateModuleCpp.js
8
8
  */
9
9
 
10
- #include "RNReactNativeCustomergluSpecJSI.h"
10
+ #include "RNCustomergluSpecJSI.h"
11
11
 
12
12
  namespace facebook::react {
13
13
 
@@ -112,7 +112,7 @@ static jsi::Value __hostFunction_NativeReactNativeCustomergluCxxSpecJSI_enableEn
112
112
  static jsi::Value __hostFunction_NativeReactNativeCustomergluCxxSpecJSI_isFcmApn(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
113
113
  static_cast<NativeReactNativeCustomergluCxxSpecJSI *>(&turboModule)->isFcmApn(
114
114
  rt,
115
- count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asBool()
115
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
116
116
  );
117
117
  return jsi::Value::undefined();
118
118
  }
@@ -28,13 +28,13 @@ public:
28
28
  virtual void sendData(jsi::Runtime &rt, jsi::Object obj) = 0;
29
29
  virtual void openWallet(jsi::Runtime &rt, std::optional<jsi::Object> obj) = 0;
30
30
  virtual void initCGSDK(jsi::Runtime &rt, jsi::String obj) = 0;
31
- virtual void loadCampaignById(jsi::Runtime &rt, jsi::String id, std::optional<jsi::Object> obj) = 0;
31
+ virtual void loadCampaignById(jsi::Runtime &rt, jsi::String campid, std::optional<jsi::Object> obj) = 0;
32
32
  virtual void loadCampaignWithUrl(jsi::Runtime &rt, jsi::String url, jsi::Object obj) = 0;
33
33
  virtual void enableAnalytic(jsi::Runtime &rt, bool b) = 0;
34
34
  virtual void allowAnonymousRegistration(jsi::Runtime &rt, bool b) = 0;
35
35
  virtual void gluSDKDebuggingMode(jsi::Runtime &rt, bool b) = 0;
36
36
  virtual void enableEntryPoints(jsi::Runtime &rt, bool b) = 0;
37
- virtual void isFcmApn(jsi::Runtime &rt, bool id) = 0;
37
+ virtual void isFcmApn(jsi::Runtime &rt, jsi::String value) = 0;
38
38
  virtual void UpdateProfile(jsi::Runtime &rt, jsi::Object obj) = 0;
39
39
  virtual void DisplayCustomerGluNotification(jsi::Runtime &rt) = 0;
40
40
  virtual void DisplayCGNotification(jsi::Runtime &rt, jsi::Object obj, std::optional<bool> autoclosewebview) = 0;
@@ -141,13 +141,13 @@ private:
141
141
  return bridging::callFromJs<void>(
142
142
  rt, &T::initCGSDK, jsInvoker_, instance_, std::move(obj));
143
143
  }
144
- void loadCampaignById(jsi::Runtime &rt, jsi::String id, std::optional<jsi::Object> obj) override {
144
+ void loadCampaignById(jsi::Runtime &rt, jsi::String campid, std::optional<jsi::Object> obj) override {
145
145
  static_assert(
146
146
  bridging::getParameterCount(&T::loadCampaignById) == 3,
147
147
  "Expected loadCampaignById(...) to have 3 parameters");
148
148
 
149
149
  return bridging::callFromJs<void>(
150
- rt, &T::loadCampaignById, jsInvoker_, instance_, std::move(id), std::move(obj));
150
+ rt, &T::loadCampaignById, jsInvoker_, instance_, std::move(campid), std::move(obj));
151
151
  }
152
152
  void loadCampaignWithUrl(jsi::Runtime &rt, jsi::String url, jsi::Object obj) override {
153
153
  static_assert(
@@ -189,13 +189,13 @@ private:
189
189
  return bridging::callFromJs<void>(
190
190
  rt, &T::enableEntryPoints, jsInvoker_, instance_, std::move(b));
191
191
  }
192
- void isFcmApn(jsi::Runtime &rt, bool id) override {
192
+ void isFcmApn(jsi::Runtime &rt, jsi::String value) override {
193
193
  static_assert(
194
194
  bridging::getParameterCount(&T::isFcmApn) == 2,
195
195
  "Expected isFcmApn(...) to have 2 parameters");
196
196
 
197
197
  return bridging::callFromJs<void>(
198
- rt, &T::isFcmApn, jsInvoker_, instance_, std::move(id));
198
+ rt, &T::isFcmApn, jsInvoker_, instance_, std::move(value));
199
199
  }
200
200
  void UpdateProfile(jsi::Runtime &rt, jsi::Object obj) override {
201
201
  static_assert(
@@ -0,0 +1,16 @@
1
+ #import <React/RCTView.h>
2
+ #import <WebKit/WebKit.h>
3
+ #import <UserNotifications/UserNotifications.h>
4
+ #import <UserNotifications/UNNotification.h>
5
+ #import <UIKit/UIKit.h>
6
+
7
+ NS_ASSUME_NONNULL_BEGIN
8
+
9
+ @interface IosBannerView : RCTView
10
+
11
+ @property (nonatomic, strong) NSString *bannerId;
12
+ - (void)setBannerId:(NSString *)bannerId;
13
+
14
+ @end
15
+
16
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,126 @@
1
+ #import "IosBannerView.h"
2
+ #import <WebKit/WebKit.h>
3
+ #import <UserNotifications/UserNotifications.h>
4
+ #import <UserNotifications/UNNotification.h>
5
+ #import <CustomerGlu/CustomerGlu-Swift.h>
6
+ #import <objc/runtime.h>
7
+
8
+ @implementation IosBannerView {
9
+ BannerView *_bannerView;
10
+ NSString *_bannerId;
11
+ BOOL _bannerInitialized;
12
+ BOOL _isHeightUpdated;
13
+ }
14
+
15
+ - (instancetype)initWithFrame:(CGRect)frame {
16
+ if (self = [super initWithFrame:frame]) {
17
+ // Initialize view
18
+ self.userInteractionEnabled = YES;
19
+ _bannerInitialized = NO;
20
+ NSLog(@"[IosView] Initialized with frame: %@, userInteractionEnabled: %d", NSStringFromCGRect(frame), self.userInteractionEnabled);
21
+ }
22
+ return self;
23
+ }
24
+
25
+ - (void)setBannerId:(NSString *)bannerId {
26
+ NSLog(@"[IosView] setBannerId called with: %@", bannerId);
27
+ _bannerId = bannerId;
28
+
29
+ if (!_bannerInitialized || ![_bannerId isEqualToString:bannerId]) {
30
+ // Remove existing banner if any
31
+ if (_bannerView) {
32
+ [_bannerView removeFromSuperview];
33
+ _bannerView = nil;
34
+ NSLog(@"[IosView] Removed existing banner view");
35
+ }
36
+
37
+ if (bannerId) {
38
+ [self createBannerView];
39
+ }
40
+ }
41
+ }
42
+
43
+ - (void)createBannerView {
44
+ NSLog(@"[IosView] Creating banner view");
45
+ dispatch_async(dispatch_get_main_queue(), ^{
46
+ self->_bannerView = [[BannerView alloc] initWithFrame:self.bounds bannerId:self->_bannerId];
47
+
48
+ if (self->_bannerView) {
49
+ self.userInteractionEnabled = YES;
50
+ self->_bannerView.userInteractionEnabled = YES;
51
+ NSLog(@"[IosView] Banner view created, userInteractionEnabled: %d", self->_bannerView.userInteractionEnabled);
52
+
53
+ [self addSubview:self->_bannerView];
54
+ self->_bannerView.frame = self.bounds;
55
+ self->_bannerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
56
+ self->_bannerInitialized = YES;
57
+ [self setNeedsLayout];
58
+
59
+ } else {
60
+ [self showError:@"Failed to create banner view"];
61
+ NSLog(@"[IosView] Failed to create banner view");
62
+ }
63
+ });
64
+ }
65
+
66
+ - (void)showError:(NSString *)message {
67
+ UILabel *errorLabel = [[UILabel alloc] init];
68
+ errorLabel.text = message;
69
+ errorLabel.textColor = [UIColor redColor];
70
+ errorLabel.textAlignment = NSTextAlignmentCenter;
71
+ errorLabel.numberOfLines = 0;
72
+ [self addSubview:errorLabel];
73
+ errorLabel.frame = self.bounds;
74
+ }
75
+
76
+ //- (void)layoutSubviews {
77
+ // [super layoutSubviews];
78
+ //
79
+ // if (_bannerView) {
80
+ // _bannerView.frame = self.bounds;
81
+ // }
82
+ //}
83
+
84
+ //- (void)didMoveToSuperview {
85
+ // [super didMoveToSuperview];
86
+ //
87
+ // if (_bannerId && !_bannerView) {
88
+ // NSLog(@"[IosView] didMoveToSuperview - recreating banner view");
89
+ // [self createBannerView];
90
+ // }
91
+ //}
92
+ //
93
+ //- (void)didMoveToWindow {
94
+ // [super didMoveToWindow];
95
+ //
96
+ // if (self.window && _bannerId && !_bannerView) {
97
+ // NSLog(@"[IosView] didMoveToWindow - recreating banner view");
98
+ // [self createBannerView];
99
+ // }
100
+ //}
101
+
102
+ // Direct touch handling to manually forward touches to BannerView
103
+ - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
104
+ NSLog(@"[IosView] touchesBegan detected in IosView");
105
+
106
+ if (_bannerView) {
107
+ UITouch *touch = [touches anyObject];
108
+ CGPoint point = [touch locationInView:self];
109
+
110
+ // Check if the touch is within the banner view
111
+ if (CGRectContainsPoint(_bannerView.frame, point)) {
112
+ NSLog(@"[IosView] Touch is within banner view bounds");
113
+
114
+ // Option 1: Try calling handleTap: with nil since we can't create a properly configured gesture recognizer
115
+ NSLog(@"[IosView] Directly calling handleTap: on BannerView");
116
+ [_bannerView performSelector:@selector(handleTap:) withObject:nil];
117
+
118
+ // Don't call super so we consume the event
119
+ return;
120
+ }
121
+ }
122
+
123
+ [super touchesBegan:touches withEvent:event];
124
+ }
125
+
126
+ @end
@@ -0,0 +1,24 @@
1
+ #import <React/RCTViewManager.h>
2
+ #import <WebKit/WebKit.h>
3
+ #import <UserNotifications/UserNotifications.h>
4
+ #import <UserNotifications/UNNotification.h>
5
+ #import "IosBannerView.h"
6
+
7
+ @interface IosBannerViewManager : RCTViewManager
8
+ @end
9
+
10
+ @implementation IosBannerViewManager
11
+
12
+ RCT_EXPORT_MODULE(BannerView)
13
+
14
+ - (UIView *)view {
15
+ return [[IosBannerView alloc] init];
16
+ }
17
+
18
+ RCT_EXPORT_VIEW_PROPERTY(bannerId, NSString)
19
+
20
+ + (BOOL)requiresMainQueueSetup {
21
+ return YES;
22
+ }
23
+
24
+ @end
@@ -0,0 +1,19 @@
1
+ //
2
+ // ReactNativeCustomerglu-Bridging-Header.h
3
+ // Pods
4
+ //
5
+ // Created by Himanshu Trehan on 27/02/25.
6
+ //
7
+
8
+ #ifndef ReactNativeCustomerglu_Bridging_Header_h
9
+ #define ReactNativeCustomerglu_Bridging_Header_h
10
+
11
+ #import "React/RCTBridgeModule.h"
12
+ #import "React/RCTEventEmitter.h"
13
+
14
+ #import <ReactNativeCustomerglu/Rncustomerglu.h>
15
+ #import <WebKit/WebKit.h>
16
+ #import <UserNotifications/UserNotifications.h>
17
+ #import <UserNotifications/UNNotification.h>
18
+
19
+ #endif /* ReactNativeCustomerglu_Bridging_Header_h */
@@ -1,6 +1,9 @@
1
1
 
2
- #import "generated/RNReactNativeCustomergluSpec/RNReactNativeCustomergluSpec.h"
2
+ #import "generated/RNCustomergluSpec/RNCustomergluSpec.h"
3
+ #import <WebKit/WebKit.h>
4
+ #import <UserNotifications/UNNotification.h>
5
+ #import <React/RCTEventEmitter.h>
3
6
 
4
- @interface Rncustomerglu : NSObject <NativeRncustomergluSpec>
7
+ @interface Rncustomerglu : RCTEventEmitter <NativeReactNativeCustomergluSpec>
5
8
 
6
9
  @end