@customerglu/react-native-customerglu 2.1.2-1.0-beta → 3.0.0-beta-1.1
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/LICENSE +20 -15
- package/README.md +2 -2
- package/ReactNativeCustomerglu.podspec +47 -0
- package/android/build.gradle +78 -33
- package/android/generated/java/com/customerglu/reactnativecustomerglu/NativeReactNativeCustomergluSpec.java +144 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNCustomergluSpec-generated.cpp +188 -0
- package/android/generated/jni/RNCustomergluSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNCustomergluSpec/RNCustomergluSpecJSI-generated.cpp +237 -0
- package/android/generated/jni/react/renderer/components/RNCustomergluSpec/RNCustomergluSpecJSI.h +305 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -6
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/BannerView.kt +76 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/BannerViewManager.kt +19 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/CGEmbededView.kt +102 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/CGEmbededViewManager.kt +18 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/RnCustomergluModule.kt +698 -0
- package/android/src/main/java/com/customerglu/reactnativecustomerglu/RnCustomergluPackage.kt +41 -0
- package/ios/IosBannerView.h +16 -0
- package/ios/IosBannerView.mm +126 -0
- package/ios/IosBannerViewManager.mm +24 -0
- package/ios/ReactNativeCustomerglu-Bridging-Header.h +19 -0
- package/ios/Rncustomerglu.h +9 -0
- package/ios/Rncustomerglu.mm +499 -0
- package/ios/generated/RNCustomergluSpec/RNCustomergluSpec-generated.mm +221 -0
- package/ios/generated/RNCustomergluSpec/RNCustomergluSpec.h +106 -0
- package/ios/generated/RNCustomergluSpecJSI-generated.cpp +237 -0
- package/ios/generated/RNCustomergluSpecJSI.h +305 -0
- package/lib/commonjs/NativeReactNativeCustomerglu.js +9 -0
- package/lib/commonjs/NativeReactNativeCustomerglu.js.map +1 -0
- package/lib/commonjs/index.js +30 -193
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/NativeReactNativeCustomerglu.js +5 -0
- package/lib/module/NativeReactNativeCustomerglu.js.map +1 -0
- package/lib/module/index.js +32 -166
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeReactNativeCustomerglu.d.ts +33 -0
- package/lib/typescript/commonjs/src/NativeReactNativeCustomerglu.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +35 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeReactNativeCustomerglu.d.ts +33 -0
- package/lib/typescript/module/src/NativeReactNativeCustomerglu.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +35 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +91 -45
- package/react-native.config.js +12 -0
- package/src/NativeReactNativeCustomerglu.ts +36 -0
- package/src/index.tsx +76 -216
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +0 -5
- package/android/gradlew +0 -185
- package/android/gradlew.bat +0 -89
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/Bannerwidget/BannerWidgetViewGroupManager.java +0 -40
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/Bannerwidget/bannerWidget.java +0 -43
- package/android/src/main/java/com/reactnativerncustomerglu/Bannerwidget/wrapperview/WrapperView.java +0 -61
- package/android/src/main/java/com/reactnativerncustomerglu/CGUtils.java +0 -13
- package/android/src/main/java/com/reactnativerncustomerglu/EmbedBannerwidget/EWrapperview/EWrapperView.java +0 -61
- package/android/src/main/java/com/reactnativerncustomerglu/EmbedBannerwidget/EmbedBannerwidget/EBannerWidget.java +0 -35
- package/android/src/main/java/com/reactnativerncustomerglu/EmbedBannerwidget/EmbedBannerwidget/EBannerWidgetVGManager.java +0 -40
- package/android/src/main/java/com/reactnativerncustomerglu/RncustomergluModule.java +0 -1033
- package/android/src/main/java/com/reactnativerncustomerglu/RncustomergluPackage.java +0 -35
- package/android/src/main/res/drawable/bottom_sheet_edges.xml +0 -7
- package/android/src/main/res/drawable/floating_close_layout.xml +0 -10
- package/android/src/main/res/drawable/ic_arrow_back.xml +0 -5
- package/android/src/main/res/drawable/ic_back.xml +0 -10
- package/android/src/main/res/drawable/ic_delete_bin.xml +0 -5
- package/android/src/main/res/drawable/ic_delete_bin_red.xml +0 -5
- package/android/src/main/res/drawable/ij.png +0 -0
- package/android/src/main/res/drawable/notification.png +0 -0
- package/android/src/main/res/drawable/progress_bg.xml +0 -33
- package/android/src/main/res/values/colors.xml +0 -13
- package/android/src/main/res/values/themes.xml +0 -15
- package/android/src/main/res/xml/provider_path.xml +0 -4
- package/ios/CustomPlayer.m +0 -30
- package/ios/Rncustomerglu-Bridging-Header.h +0 -4
- package/ios/Rncustomerglu.m +0 -83
- package/ios/Rncustomerglu.swift +0 -647
- package/ios/Rncustomerglu.xcodeproj/project.pbxproj +0 -293
- package/ios/Rncustomerglu.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/Rncustomerglu.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/lib/typescript/index.d.ts +0 -62
- package/react-native-customerglu.podspec +0 -23
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
#import "Rncustomerglu.h"
|
|
2
|
+
#import "CustomerGlu/CustomerGlu-Swift.h"
|
|
3
|
+
|
|
4
|
+
#import <WebKit/WebKit.h>
|
|
5
|
+
#import <UserNotifications/UserNotifications.h>
|
|
6
|
+
#import <UserNotifications/UNNotification.h>
|
|
7
|
+
|
|
8
|
+
@implementation Rncustomerglu {
|
|
9
|
+
bool hasListeners;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_MODULE(Rncustomerglu);
|
|
13
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
14
|
+
return @[
|
|
15
|
+
@"CUSTOMERGLU_ANALYTICS_EVENT",
|
|
16
|
+
@"CUSTOMERGLU_DEEPLINK_EVENT",
|
|
17
|
+
@"CGBANNER_FINAL_HEIGHT",
|
|
18
|
+
@"CUSTOMERGLU_BANNER_LOADED",
|
|
19
|
+
@"CGEMBED_FINAL_HEIGHT",
|
|
20
|
+
@"CG_INVALID_CAMPAIGN_ID",
|
|
21
|
+
@"CG_UNI_DEEPLINK_EVENT"
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Test method to verify event emission is working
|
|
26
|
+
RCT_EXPORT_METHOD(testEventEmission) {
|
|
27
|
+
NSDictionary *testData = @{@"message": @"Test event from native",
|
|
28
|
+
@"timestamp": @([[NSDate date] timeIntervalSince1970])};
|
|
29
|
+
NSLog(@"[CustomerGlu] Testing event emission with data: %@", testData);
|
|
30
|
+
|
|
31
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
32
|
+
[self sendEventWithName:@"CUSTOMERGLU_ANALYTICS_EVENT" body:testData];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Generic event handler method
|
|
37
|
+
- (void)handleEvent:(NSNotification *)notification {
|
|
38
|
+
NSString *eventName = notification.name;
|
|
39
|
+
NSDictionary *eventData = notification.userInfo;
|
|
40
|
+
|
|
41
|
+
NSLog(@"[CustomerGlu] Event received: %@ with data: %@", eventName, eventData);
|
|
42
|
+
|
|
43
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
44
|
+
if (self->hasListeners) {
|
|
45
|
+
NSLog(@"[CustomerGlu] hasListeners is YES, sending event: %@", eventName);
|
|
46
|
+
[self sendEventWithName:eventName body:eventData];
|
|
47
|
+
} else {
|
|
48
|
+
NSLog(@"[CustomerGlu] hasListeners is NO, not sending event");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Start observing events
|
|
54
|
+
- (void)startObserving {
|
|
55
|
+
hasListeners = YES;
|
|
56
|
+
NSLog(@"[CustomerGlu] Started observing for events - hasListeners is now YES");
|
|
57
|
+
|
|
58
|
+
NSArray *events = @[
|
|
59
|
+
@"CUSTOMERGLU_ANALYTICS_EVENT",
|
|
60
|
+
@"CUSTOMERGLU_DEEPLINK_EVENT",
|
|
61
|
+
@"CGBANNER_FINAL_HEIGHT",
|
|
62
|
+
@"CUSTOMERGLU_BANNER_LOADED",
|
|
63
|
+
@"CGEMBED_FINAL_HEIGHT",
|
|
64
|
+
@"CG_INVALID_CAMPAIGN_ID",
|
|
65
|
+
@"CG_UNI_DEEPLINK_EVENT"
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
for (NSString *event in events) {
|
|
69
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
70
|
+
selector:@selector(handleEvent:)
|
|
71
|
+
name:event
|
|
72
|
+
object:nil];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Stop observing events
|
|
77
|
+
- (void)stopObserving {
|
|
78
|
+
hasListeners = NO;
|
|
79
|
+
NSLog(@"[CustomerGlu] Stopped observing for events - hasListeners is now NO");
|
|
80
|
+
|
|
81
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
85
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
86
|
+
{
|
|
87
|
+
return std::make_shared<facebook::react::NativeReactNativeCustomergluSpecJSI>(params);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
- (void)DisplayCGBackgroundNotification:(nonnull NSDictionary *)obj autoclosewebview:(nonnull NSNumber *)autoclosewebview {
|
|
91
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
92
|
+
|
|
93
|
+
@try {
|
|
94
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
95
|
+
[sdk displayBackgroundNotificationWithRemoteMessage:obj auto_close_webview:autoclosewebview];
|
|
96
|
+
|
|
97
|
+
});
|
|
98
|
+
} @catch (NSException *exception) {
|
|
99
|
+
NSLog(@"CustomerGlu displayBackgroundNotificationWithRemoteMessage failed: %@", exception.reason);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
- (void)DisplayCGNotification:(nonnull NSDictionary *)obj autoclosewebview:(nonnull NSNumber *)autoclosewebview {
|
|
104
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
105
|
+
|
|
106
|
+
@try {
|
|
107
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
108
|
+
[sdk displayBackgroundNotificationWithRemoteMessage:obj auto_close_webview:autoclosewebview];
|
|
109
|
+
|
|
110
|
+
});
|
|
111
|
+
} @catch (NSException *exception) {
|
|
112
|
+
NSLog(@"CustomerGlu DisplayCGNotification failed: %@", exception.reason);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)DisplayCustomerGluNotification {
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
- (void)SetCurrentClassName:(nonnull NSString *)clname resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
121
|
+
|
|
122
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
123
|
+
|
|
124
|
+
@try {
|
|
125
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
126
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
127
|
+
[sdk setCurrentClassNameWithClassName:clname];
|
|
128
|
+
resolve(clname);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
} @catch (NSException *exception) {
|
|
132
|
+
NSLog(@"CustomerGlu clearGluData failed: %@", exception.reason);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)UpdateProfile:(nonnull NSDictionary *)obj {
|
|
138
|
+
|
|
139
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
140
|
+
|
|
141
|
+
@try {
|
|
142
|
+
[sdk updateProfileWithUserdata:obj];
|
|
143
|
+
|
|
144
|
+
} @catch (NSException *exception) {
|
|
145
|
+
NSLog(@"CustomerGlu updateProfileWithUserdata failed: %@", exception.reason);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (void)UpdateUserAttributes:(nonnull NSDictionary *)userdata {
|
|
152
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
153
|
+
|
|
154
|
+
@try {
|
|
155
|
+
[sdk updateUserAttributesWithCustomAttributes:userdata];
|
|
156
|
+
|
|
157
|
+
} @catch (NSException *exception) {
|
|
158
|
+
NSLog(@"CustomerGlu UpdateUserAttributes failed: %@", exception.reason);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
- (void)addDelayForPIP:(double)delay {
|
|
163
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
164
|
+
|
|
165
|
+
@try {
|
|
166
|
+
[sdk addDelayForPIPWithDelay:delay];
|
|
167
|
+
} @catch (NSException *exception) {
|
|
168
|
+
NSLog(@"CustomerGlu addDelayForPIPWithDelay failed: %@", exception.reason);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
- (void)addListener:(nonnull NSString *)eventType {
|
|
173
|
+
[super addListener:eventType];
|
|
174
|
+
NSLog(@"[CustomerGlu] JS added listener for %@", eventType);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
- (void)addMarginsForPIP:(double)horizontal vertical:(double)vertical type:(nonnull NSString *)type {
|
|
178
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
179
|
+
|
|
180
|
+
@try {
|
|
181
|
+
[sdk addMarginForPIPWithHorizontal:horizontal vertical:vertical];
|
|
182
|
+
} @catch (NSException *exception) {
|
|
183
|
+
NSLog(@"CustomerGlu clearGluData failed: %@", exception.reason);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
- (void)allowAnonymousRegistration:(BOOL)b {
|
|
188
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
189
|
+
|
|
190
|
+
@try {
|
|
191
|
+
[sdk allowAnonymousRegistrationWithEnabled:b];
|
|
192
|
+
} @catch (NSException *exception) {
|
|
193
|
+
NSLog(@"CustomerGlu allowAnonymousRegistrationWithEnabled failed: %@", exception.reason);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
- (void)dataClear {
|
|
198
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
199
|
+
|
|
200
|
+
@try {
|
|
201
|
+
[sdk clearGluData];
|
|
202
|
+
} @catch (NSException *exception) {
|
|
203
|
+
NSLog(@"CustomerGlu clearGluData failed: %@", exception.reason);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
- (void)enableAnalytic:(BOOL)b {
|
|
208
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
209
|
+
|
|
210
|
+
@try {
|
|
211
|
+
[sdk enableAnalyticsEventWithEvent:b];
|
|
212
|
+
} @catch (NSException *exception) {
|
|
213
|
+
NSLog(@"CustomerGlu enableAnalyticsEventWithEvent failed: %@", exception.reason);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
- (void)enableEntryPoints:(BOOL)b {
|
|
218
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
219
|
+
|
|
220
|
+
@try {
|
|
221
|
+
[sdk enableEntryPointsWithEnabled:b];
|
|
222
|
+
} @catch (NSException *exception) {
|
|
223
|
+
NSLog(@"CustomerGlu enableEntryPoints failed: %@", exception.reason);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
- (void)getBannerHeight:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
- (void)getCampaignStatus:(nonnull NSString *)campaignId dataFlag:(nonnull NSString *)dataFlag resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
232
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
233
|
+
|
|
234
|
+
@try {
|
|
235
|
+
// Convert NSString to CAMPAIGNDATA enum value
|
|
236
|
+
CAMPAIGNDATA dataFlagEnum;
|
|
237
|
+
|
|
238
|
+
if ([dataFlag caseInsensitiveCompare:@"API"] == NSOrderedSame) {
|
|
239
|
+
dataFlagEnum = CAMPAIGNDATAAPI;
|
|
240
|
+
} else if ([dataFlag caseInsensitiveCompare:@"CACHE"] == NSOrderedSame) {
|
|
241
|
+
dataFlagEnum = CAMPAIGNDATACACHE;
|
|
242
|
+
} else {
|
|
243
|
+
// Default to API if unknown value is provided
|
|
244
|
+
dataFlagEnum = CAMPAIGNDATAAPI;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
[sdk getCampaignStatusWithCampaignId:campaignId dataType:dataFlagEnum completion:^(CAMPAIGN_STATE campaignStatus) {
|
|
248
|
+
NSString *statusString;
|
|
249
|
+
|
|
250
|
+
// Convert enum value to string based on the typedef
|
|
251
|
+
switch (campaignStatus) {
|
|
252
|
+
case CAMPAIGN_STATEIN_PROGRESS:
|
|
253
|
+
statusString = @"IN_PROGRESS";
|
|
254
|
+
break;
|
|
255
|
+
case CAMPAIGN_STATEPRISTINE:
|
|
256
|
+
statusString = @"PRISTINE";
|
|
257
|
+
break;
|
|
258
|
+
case CAMPAIGN_STATECOMPLETED:
|
|
259
|
+
statusString = @"COMPLETED";
|
|
260
|
+
break;
|
|
261
|
+
case CAMPAIGN_STATENOT_ELIGIBLE:
|
|
262
|
+
statusString = @"NOT_ELIGIBLE";
|
|
263
|
+
break;
|
|
264
|
+
default:
|
|
265
|
+
statusString = @"UNKNOWN";
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
resolve(statusString);
|
|
272
|
+
}];
|
|
273
|
+
} @catch (NSException *exception) {
|
|
274
|
+
NSLog(@"CustomerGlu getCampaignStatus failed: %@", exception.reason);
|
|
275
|
+
reject(@"campaign_status_error", exception.reason, nil);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
- (void)gluSDKDebuggingMode:(BOOL)b {
|
|
281
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
282
|
+
|
|
283
|
+
@try {
|
|
284
|
+
[sdk gluSDKDebuggingModeWithEnabled:YES];
|
|
285
|
+
} @catch (NSException *exception) {
|
|
286
|
+
NSLog(@"CustomerGlu initialization failed: %@", exception.reason);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
- (void)initCGSDK:(nonnull NSString *)obj {
|
|
291
|
+
NSLog(@"[CustomerGlu] start init sdk");
|
|
292
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
293
|
+
|
|
294
|
+
@try {
|
|
295
|
+
[self startObserving];
|
|
296
|
+
[sdk initializeSdkWithMyenv:obj];
|
|
297
|
+
} @catch (NSException *exception) {
|
|
298
|
+
NSLog(@"CustomerGlu initialization failed: %@", exception.reason);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
- (void)isCampaignValid:(nonnull NSString *)campaignId dataFlag:(nonnull NSString *)dataFlag resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
304
|
+
|
|
305
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
306
|
+
|
|
307
|
+
@try {
|
|
308
|
+
// Convert NSString to CAMPAIGNDATA enum value
|
|
309
|
+
CAMPAIGNDATA dataFlagEnum;
|
|
310
|
+
|
|
311
|
+
if ([dataFlag caseInsensitiveCompare:@"API"] == NSOrderedSame) {
|
|
312
|
+
dataFlagEnum = CAMPAIGNDATAAPI;
|
|
313
|
+
} else if ([dataFlag caseInsensitiveCompare:@"CACHE"] == NSOrderedSame) {
|
|
314
|
+
dataFlagEnum = CAMPAIGNDATACACHE;
|
|
315
|
+
} else {
|
|
316
|
+
// Default to API if unknown value is provided
|
|
317
|
+
dataFlagEnum = CAMPAIGNDATAAPI;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
[sdk isCampaignValidWithCampaignId:campaignId dataType:dataFlagEnum completion:^(BOOL success) {
|
|
321
|
+
if (success) {
|
|
322
|
+
resolve(@(YES));
|
|
323
|
+
} else {
|
|
324
|
+
resolve(@(NO));
|
|
325
|
+
}
|
|
326
|
+
}];
|
|
327
|
+
} @catch (NSException *exception) {
|
|
328
|
+
NSLog(@"CustomerGlu getCampaignValid failed: %@", exception.reason);
|
|
329
|
+
reject(@"campaign_status_error", exception.reason, nil);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
- (void)isFcmApn:(NSString *) value {
|
|
334
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
335
|
+
|
|
336
|
+
@try {
|
|
337
|
+
[sdk isFcmApnWithFcmApn:value];
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
} @catch (NSException *exception) {
|
|
341
|
+
NSLog(@"CustomerGlu isFcm failed: %@", exception.reason);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
- (void)loadCampaignById:(nonnull NSString *)campid obj:(nonnull NSDictionary *)obj {
|
|
346
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
347
|
+
|
|
348
|
+
@try {
|
|
349
|
+
// Extract values from the dictionary with appropriate defaults
|
|
350
|
+
CGNudgeConfiguration *config = [[CGNudgeConfiguration alloc] init];
|
|
351
|
+
|
|
352
|
+
if (obj.count == 0) {
|
|
353
|
+
// If the dictionary is empty, just call the method without a configuration
|
|
354
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
355
|
+
[sdk loadCampaignByIdWithCampaign_id:campid nudgeConfiguration:config auto_close_webview:YES];
|
|
356
|
+
|
|
357
|
+
});
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Set values using KVC (Key-Value Coding)
|
|
362
|
+
for (NSString *key in obj) {
|
|
363
|
+
@try {
|
|
364
|
+
[config setValue:obj[key] forKey:key];
|
|
365
|
+
} @catch (NSException *exception) {
|
|
366
|
+
NSLog(@"Failed to set %@ on CGNudgeConfiguration: %@", key, exception.reason);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
// Call the method with the created configuration
|
|
372
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
373
|
+
[sdk loadCampaignByIdWithCampaign_id:campid nudgeConfiguration:config auto_close_webview:YES];
|
|
374
|
+
|
|
375
|
+
});
|
|
376
|
+
} @catch (NSException *exception) {
|
|
377
|
+
NSLog(@"CustomerGlu loadCampaignById failed: %@", exception.reason);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
- (void)loadCampaignWithUrl:(nonnull NSString *)url obj:(nonnull NSDictionary *)obj {
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
- (void)openWallet:(nonnull NSDictionary *)obj {
|
|
388
|
+
|
|
389
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
390
|
+
|
|
391
|
+
@try {
|
|
392
|
+
// Extract values from the dictionary with appropriate defaults
|
|
393
|
+
CGNudgeConfiguration *config = [[CGNudgeConfiguration alloc] init];
|
|
394
|
+
|
|
395
|
+
if (obj.count == 0) {
|
|
396
|
+
// If the dictionary is empty, just call the method without a configuration
|
|
397
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
398
|
+
[sdk openWalletWithNudgeConfiguration:config];
|
|
399
|
+
|
|
400
|
+
});
|
|
401
|
+
return;
|
|
402
|
+
|
|
403
|
+
}
|
|
404
|
+
// Set values using KVC (Key-Value Coding)
|
|
405
|
+
for (NSString *key in obj) {
|
|
406
|
+
@try {
|
|
407
|
+
[config setValue:obj[key] forKey:key];
|
|
408
|
+
} @catch (NSException *exception) {
|
|
409
|
+
NSLog(@"Failed to set %@ on CGNudgeConfiguration: %@", key, exception.reason);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
// Call the method with the created configuration
|
|
415
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
416
|
+
[sdk openWalletWithNudgeConfiguration:config];
|
|
417
|
+
|
|
418
|
+
});
|
|
419
|
+
} @catch (NSException *exception) {
|
|
420
|
+
NSLog(@"CustomerGlu openWallet failed: %@", exception.reason);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
- (void)registerDevice:(nonnull NSDictionary *)data resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
|
|
426
|
+
|
|
427
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
@try {
|
|
431
|
+
[sdk registerDeviceWithUserdata:data completion:^(BOOL success) {
|
|
432
|
+
if (success) {
|
|
433
|
+
resolve(@(YES));
|
|
434
|
+
} else {
|
|
435
|
+
resolve(@(NO));
|
|
436
|
+
}
|
|
437
|
+
}];
|
|
438
|
+
} @catch (NSException *exception) {
|
|
439
|
+
NSLog(@"CustomerGlu registration failed: %@", exception.reason);
|
|
440
|
+
reject(@"registration_error", exception.reason, nil);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
- (void)removeListeners:(double)count {
|
|
446
|
+
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
- (void)sendData:(nonnull NSDictionary *)obj {
|
|
450
|
+
|
|
451
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
452
|
+
|
|
453
|
+
@try {
|
|
454
|
+
// Extract event name from the dictionary - required parameter
|
|
455
|
+
NSString *eventName = obj[@"eventName"];
|
|
456
|
+
|
|
457
|
+
// Make sure eventName is present
|
|
458
|
+
if (!eventName || ![eventName isKindOfClass:[NSString class]]) {
|
|
459
|
+
NSLog(@"CustomerGlu sendData failed: eventName is required and must be a string");
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Extract event properties if present, otherwise use empty dictionary
|
|
464
|
+
NSDictionary *eventProperties = obj[@"eventProperties"];
|
|
465
|
+
if (!eventProperties || ![eventProperties isKindOfClass:[NSDictionary class]]) {
|
|
466
|
+
eventProperties = @{};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Call the method with extracted values
|
|
470
|
+
[sdk sendEventDataWithEventName:eventName eventProperties:eventProperties];
|
|
471
|
+
} @catch (NSException *exception) {
|
|
472
|
+
NSLog(@"CustomerGlu sendEvent failed: %@", exception.reason);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
- (void)setApnFcmToken:(nonnull NSString *)a b:(nonnull NSString *)b {
|
|
477
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
478
|
+
|
|
479
|
+
@try {
|
|
480
|
+
sdk.apnToken = a;
|
|
481
|
+
sdk.fcmToken = b;
|
|
482
|
+
} @catch (NSException *exception) {
|
|
483
|
+
NSLog(@"CustomerGlu setApnFcmToken failed: %@", exception.reason);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
- (void)setOpenWalletAsFallback:(BOOL)value {
|
|
488
|
+
CustomerGlu *sdk = [CustomerGlu getInstance];
|
|
489
|
+
|
|
490
|
+
@try {
|
|
491
|
+
[sdk setOpenWalletAsFallback:value];
|
|
492
|
+
|
|
493
|
+
} @catch (NSException *exception) {
|
|
494
|
+
NSLog(@"CustomerGlu isFcm failed: %@", exception.reason);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
@end
|