react-native-netmera 1.6.0 → 1.6.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.
- package/README.md +22 -0
- package/RNNetmera.podspec +1 -1
- package/android/build.gradle +4 -5
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmera.java +1 -1
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +30 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraUtil.java +29 -0
- package/ios/RNNetmera.m +33 -1
- package/ios/RNNetmeraUtils.h +1 -0
- package/ios/RNNetmeraUtils.m +14 -0
- package/package.json +1 -1
- package/src/Netmera.ts +16 -0
- package/src/models/NetmeraCouponObject.ts +11 -0
package/README.md
CHANGED
|
@@ -419,4 +419,26 @@ Note: To show popup on the app start or everywhere in the app, please add this t
|
|
|
419
419
|
Netmera.enablePopupPresentation();
|
|
420
420
|
```
|
|
421
421
|
|
|
422
|
+
##### Data Start-Stop Transfer
|
|
423
|
+
|
|
424
|
+
###### Stop Data Transfer Method
|
|
425
|
+
|
|
426
|
+
The stopDataTransfer() method is a useful feature that can help users to temporarily pause all requests sent by the SDK to the backend.
|
|
427
|
+
This can be useful if, for example, the user needs to temporarily halt data transfers due to network issues or other reasons.
|
|
428
|
+
Once the issue has been resolved, the user can then restart the data transfer using the startDataTransfer() method.
|
|
429
|
+
|
|
430
|
+
```
|
|
431
|
+
Netmera.stopDataTransfer();
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
###### Start Data Transfer Method
|
|
435
|
+
|
|
436
|
+
The startDataTransfer() method is a complementary feature to the stopDataTransfer() method, which allows users to restart any stopped requests.
|
|
437
|
+
This can be useful when the user has temporarily paused data transfers and is now ready to resume the transfer. Once the user calls the
|
|
438
|
+
startDataTransfer() method, the SDK will attempt to resend any requests that were previously stopped.
|
|
439
|
+
|
|
440
|
+
```
|
|
441
|
+
Netmera.startDataTransfer();
|
|
442
|
+
```
|
|
443
|
+
|
|
422
444
|
Please explore [our example project](https://github.com/Netmera/Netmera-React-Native-Example) for detailed information.
|
package/RNNetmera.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
android {
|
|
4
|
-
|
|
5
|
-
buildToolsVersion "29.0.2"
|
|
4
|
+
compileSdk 33
|
|
6
5
|
|
|
7
6
|
defaultConfig {
|
|
8
7
|
minSdkVersion 16
|
|
9
|
-
targetSdkVersion
|
|
8
|
+
targetSdkVersion 33
|
|
10
9
|
versionCode 1
|
|
11
10
|
versionName "1.0"
|
|
12
11
|
}
|
|
@@ -16,8 +15,8 @@ android {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
dependencies {
|
|
19
|
-
implementation 'com.netmera:nmcore:3.10.
|
|
20
|
-
implementation 'com.netmera:nmfcm:3.10.
|
|
18
|
+
implementation 'com.netmera:nmcore:3.10.4'
|
|
19
|
+
implementation 'com.netmera:nmfcm:3.10.2'
|
|
21
20
|
implementation 'com.netmera:nmhms:3.10.1'
|
|
22
21
|
implementation 'com.facebook.react:react-native:+'
|
|
23
22
|
}
|
|
@@ -23,7 +23,7 @@ public class RNNetmera {
|
|
|
23
23
|
static void setNetmeraHeaders() {
|
|
24
24
|
ContentValues headerValues = new ContentValues();
|
|
25
25
|
headerValues.put("X-netmera-framework", "react");
|
|
26
|
-
headerValues.put("X-netmera-frameworkV", "1.6.
|
|
26
|
+
headerValues.put("X-netmera-frameworkV", "1.6.2");
|
|
27
27
|
Netmera.setNetmeraHeaders(headerValues);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -28,8 +28,10 @@ import com.netmera.NetmeraInteractiveAction;
|
|
|
28
28
|
import com.netmera.NetmeraPushObject;
|
|
29
29
|
import com.netmera.callbacks.NMCategoryPreferenceFetchCallback;
|
|
30
30
|
import com.netmera.callbacks.NMCategoryPreferenceSetCallback;
|
|
31
|
+
import com.netmera.callbacks.NMFetchCouponsResultListener;
|
|
31
32
|
import com.netmera.callbacks.NMInboxCountResultListener;
|
|
32
33
|
import com.netmera.data.NMCategoryPreference;
|
|
34
|
+
import com.netmera.data.NMCouponDetail;
|
|
33
35
|
import com.netmera.data.NMInboxStatusCount;
|
|
34
36
|
import com.netmera.data.NMInboxStatusCountFilter;
|
|
35
37
|
|
|
@@ -66,6 +68,8 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
66
68
|
private static final String ERROR_MESSAGE_CATEGORY_PREFERENCE = "Error occurred while fetching user category preference list.";
|
|
67
69
|
private static final String ERROR_CODE_SET_CATEGORY_PREFERENCE = "2025";
|
|
68
70
|
private static final String ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = "Error occurred while setting user category preference list.";
|
|
71
|
+
private static final String ERROR_CODE_COUPON_FETCH = "2026";
|
|
72
|
+
private static final String ERROR_MESSAGE_COUPON_FETCH = "Error occurred while fetching coupons.";
|
|
69
73
|
|
|
70
74
|
public static ReactApplicationContext reactContext;
|
|
71
75
|
private NetmeraInbox netmeraInbox;
|
|
@@ -142,6 +146,22 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
142
146
|
Netmera.turnOffSendingEventAndUserUpdate(turnOff);
|
|
143
147
|
}
|
|
144
148
|
|
|
149
|
+
@ReactMethod
|
|
150
|
+
public void fetchCoupons(final int page, final int max, final Promise promise) {
|
|
151
|
+
Netmera.fetchCoupons(page, max, new NMFetchCouponsResultListener() {
|
|
152
|
+
|
|
153
|
+
@Override
|
|
154
|
+
public void onSuccess(@Nullable List<NMCouponDetail> list) {
|
|
155
|
+
promise.resolve(RNNetmeraUtil.mapCouponObjects(list));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@Override
|
|
159
|
+
public void onFailure(@Nullable String s) {
|
|
160
|
+
promise.reject(ERROR_CODE_COUPON_FETCH, ERROR_MESSAGE_COUPON_FETCH);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
145
165
|
@ReactMethod
|
|
146
166
|
public void fetchInbox(ReadableMap readableMap, final Promise promise) {
|
|
147
167
|
NetmeraInboxFilter.Builder builder = new NetmeraInboxFilter.Builder();
|
|
@@ -512,6 +532,16 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
512
532
|
Netmera.onNetmeraNewToken(pushToken);
|
|
513
533
|
}
|
|
514
534
|
|
|
535
|
+
@ReactMethod
|
|
536
|
+
public static void startDataTransfer() {
|
|
537
|
+
Netmera.startDataTransfer();
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
@ReactMethod
|
|
541
|
+
public static void stopDataTransfer() {
|
|
542
|
+
Netmera.stopDataTransfer();
|
|
543
|
+
}
|
|
544
|
+
|
|
515
545
|
private boolean hasKey(Map map, String key) {
|
|
516
546
|
return map.containsKey(key) && map.get(key) != null;
|
|
517
547
|
}
|
|
@@ -26,6 +26,7 @@ import com.netmera.NetmeraCarouselObject;
|
|
|
26
26
|
import com.netmera.NetmeraPushObject;
|
|
27
27
|
import com.netmera.NetmeraPushStyle;
|
|
28
28
|
import com.netmera.data.NMCategoryPreference;
|
|
29
|
+
import com.netmera.data.NMCouponDetail;
|
|
29
30
|
import com.netmera.data.NMInboxStatus;
|
|
30
31
|
import com.netmera.data.NMInboxStatusCount;
|
|
31
32
|
|
|
@@ -191,6 +192,34 @@ class RNNetmeraUtil {
|
|
|
191
192
|
return array;
|
|
192
193
|
}
|
|
193
194
|
|
|
195
|
+
public static WritableArray mapCouponObjects(List<NMCouponDetail> couponObjects) {
|
|
196
|
+
WritableArray couponObjectList = Arguments.createArray();
|
|
197
|
+
for (NMCouponDetail netmeraCouponObject : couponObjects) {
|
|
198
|
+
couponObjectList.pushMap(mapCouponObject(netmeraCouponObject));
|
|
199
|
+
}
|
|
200
|
+
return couponObjectList;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public static WritableMap mapCouponObject(NMCouponDetail couponObject) {
|
|
204
|
+
WritableMap couponObjectMap = Arguments.createMap();
|
|
205
|
+
if (couponObject == null) {
|
|
206
|
+
return couponObjectMap;
|
|
207
|
+
}
|
|
208
|
+
couponObjectMap.putString("couponId", couponObject.getCouponId());
|
|
209
|
+
couponObjectMap.putString("name", couponObject.getName());
|
|
210
|
+
couponObjectMap.putString("code", couponObject.getCode());
|
|
211
|
+
|
|
212
|
+
if (couponObject.getAssignDate() != null) {
|
|
213
|
+
couponObjectMap.putString("assignDate", couponObject.getAssignDate().toString());
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (couponObject.getExpireDate() != null) {
|
|
217
|
+
couponObjectMap.putString("expireDate", couponObject.getExpireDate().toString());
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return couponObjectMap;
|
|
221
|
+
}
|
|
222
|
+
|
|
194
223
|
public static WritableArray mapPushObjects(List<NetmeraPushObject> pushObjects) {
|
|
195
224
|
WritableArray pushObjectList = Arguments.createArray();
|
|
196
225
|
for (NetmeraPushObject netmeraPushObject : pushObjects) {
|
package/ios/RNNetmera.m
CHANGED
|
@@ -31,6 +31,8 @@ NSString *const ERROR_CODE_GET_CATEGORY_PREFERENCE = @"2024";
|
|
|
31
31
|
NSString *const ERROR_MESSAGE_GET_CATEGORY_PREFERENCE = @"Error occurred while fetching user category preference list.";
|
|
32
32
|
NSString *const ERROR_CODE_SET_CATEGORY_PREFERENCE = @"2025";
|
|
33
33
|
NSString *const ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = @"Error occurred while setting user category preference list.";
|
|
34
|
+
NSString *const ERROR_CODE_COUPON_FETCH = @"2026";
|
|
35
|
+
NSString *const ERROR_MESSAGE_COUPON_FETCH = @"Error occurred while fetching coupons.";
|
|
34
36
|
|
|
35
37
|
@implementation RNNetmera
|
|
36
38
|
|
|
@@ -46,7 +48,7 @@ NSString *const ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = @"Error occurred while s
|
|
|
46
48
|
|
|
47
49
|
+ (void)setNetmeraHeaders {
|
|
48
50
|
[Netmera setFramework:@"react"];
|
|
49
|
-
[Netmera setFrameworkVersion:@"1.6.
|
|
51
|
+
[Netmera setFrameworkVersion:@"1.6.2"];
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
+ (void)setPushDelegate:(NSObject<NetmeraPushDelegate> *)delegate {
|
|
@@ -123,6 +125,36 @@ RCT_EXPORT_METHOD(disablePush) {
|
|
|
123
125
|
[Netmera setEnabledReceivingPushNotifications:false];
|
|
124
126
|
}
|
|
125
127
|
|
|
128
|
+
RCT_EXPORT_METHOD(startDataTransfer) {
|
|
129
|
+
[Netmera startDataTransfer];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
RCT_EXPORT_METHOD(stopDataTransfer) {
|
|
133
|
+
[Netmera stopDataTransfer];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
RCT_EXPORT_METHOD(fetchCoupons:(int)page
|
|
137
|
+
max: (int)max
|
|
138
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
139
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
140
|
+
NetmeraCouponFilter *filter = [[NetmeraCouponFilter alloc] init];
|
|
141
|
+
|
|
142
|
+
filter.page = page;
|
|
143
|
+
filter.max = max;
|
|
144
|
+
|
|
145
|
+
[Netmera fetchCouponUsingFilter:filter completion:^(NSArray<NetmeraCouponObject *> *coupons, NSError *error) {
|
|
146
|
+
if (error) {
|
|
147
|
+
reject(ERROR_CODE_COUPON_FETCH, ERROR_MESSAGE_COUPON_FETCH, nil);
|
|
148
|
+
} else {
|
|
149
|
+
NSMutableArray *array = [[NSMutableArray alloc]init];
|
|
150
|
+
for(NetmeraCouponObject *object in coupons){
|
|
151
|
+
[array addObject:[[RNNetmeraUtils shared] dictionaryFromCouponObject:object]];
|
|
152
|
+
}
|
|
153
|
+
resolve(array);
|
|
154
|
+
}
|
|
155
|
+
}];
|
|
156
|
+
}
|
|
157
|
+
|
|
126
158
|
RCT_EXPORT_METHOD(fetchInbox:(NSDictionary *)inboxDictionary
|
|
127
159
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
128
160
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
package/ios/RNNetmeraUtils.h
CHANGED
|
@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
15
15
|
|
|
16
16
|
+(RNNetmeraUtils *)shared;
|
|
17
17
|
|
|
18
|
+
-(NSDictionary *)dictionaryFromCouponObject:(NetmeraCouponObject *)couponObject;
|
|
18
19
|
-(NSDictionary *)dictionaryFromPushObject:(NetmeraPushObject *)pushObject;
|
|
19
20
|
-(NetmeraInboxStatus)getInboxStatus:(NSUInteger) code;
|
|
20
21
|
-(NSDictionary *)parseInboxCountForStatusToMap:(NetmeraInboxCountResponse *) response;
|
package/ios/RNNetmeraUtils.m
CHANGED
|
@@ -20,6 +20,20 @@ static RNNetmeraUtils *utils;
|
|
|
20
20
|
return utils;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
-(NSDictionary *)dictionaryFromCouponObject:(NetmeraCouponObject *)couponObject{
|
|
24
|
+
NSTimeInterval assignDateTs = [[couponObject assignDate] timeIntervalSince1970];
|
|
25
|
+
NSTimeInterval expireDateTs = [[couponObject expireDate] timeIntervalSince1970];
|
|
26
|
+
|
|
27
|
+
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
28
|
+
data[@"couponId"] = [couponObject couponId];
|
|
29
|
+
data[@"name"] = [couponObject name];
|
|
30
|
+
data[@"code"] = [couponObject code];
|
|
31
|
+
data[@"assignDate"] = [NSString stringWithFormat:@"%f", assignDateTs];
|
|
32
|
+
data[@"expireDate"] = [NSString stringWithFormat:@"%f", expireDateTs];
|
|
33
|
+
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
|
|
23
37
|
-(NSDictionary *)dictionaryFromPushObject:(NetmeraPushObject *)pushObject{
|
|
24
38
|
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
25
39
|
data[@"pushType"] = [NSNumber numberWithInteger:[pushObject pushType]];
|
package/package.json
CHANGED
package/src/Netmera.ts
CHANGED
|
@@ -18,6 +18,7 @@ import NetmeraCategory from "./models/NetmeraCategory";
|
|
|
18
18
|
import NMInboxStatusCountFilter from "./models/NMInboxStatusCountFilter";
|
|
19
19
|
import NMCategoryPreference from "./models/NMCategoryPreference";
|
|
20
20
|
import { NMInboxStatus } from "./models/NMInboxStatus";
|
|
21
|
+
import NetmeraCouponObject from "./models/NetmeraCouponObject";
|
|
21
22
|
|
|
22
23
|
const { RNNetmera, RNNetmeraRCTEventEmitter }: NativeModulesStatic =
|
|
23
24
|
NativeModules;
|
|
@@ -133,6 +134,21 @@ export default class Netmera {
|
|
|
133
134
|
}
|
|
134
135
|
};
|
|
135
136
|
|
|
137
|
+
static startDataTransfer = () => {
|
|
138
|
+
RNNetmera.startDataTransfer();
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
static stopDataTransfer = () => {
|
|
142
|
+
RNNetmera.stopDataTransfer();
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
static fetchCoupons = (
|
|
146
|
+
page: number,
|
|
147
|
+
max: number
|
|
148
|
+
): Promise<Array<NetmeraCouponObject>> => {
|
|
149
|
+
return RNNetmera.fetchCoupons(page, max);
|
|
150
|
+
};
|
|
151
|
+
|
|
136
152
|
static fetchInbox = (
|
|
137
153
|
netmeraInboxFilter: NetmeraInboxFilter
|
|
138
154
|
): Promise<Array<NetmeraPushInbox>> => {
|