react-native-netmera 1.6.3 → 1.7.0
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 +26 -3
- package/RNNetmera.podspec +1 -1
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmera.java +1 -1
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +16 -2
- package/ios/RNNetmera.m +32 -5
- package/ios/RNNetmeraRCTEventEmitter.h +3 -1
- package/ios/RNNetmeraRCTEventEmitter.m +11 -0
- package/package.json +1 -1
- package/src/Netmera.ts +12 -3
package/README.md
CHANGED
|
@@ -210,9 +210,9 @@ export const onPushReceive = async (message) => {
|
|
|
210
210
|
|
|
211
211
|
```
|
|
212
212
|
// For receiving Media Push, you must add Netmera pods to top of your Podfile.
|
|
213
|
-
pod "Netmera", "3.
|
|
214
|
-
pod "Netmera/NotificationServiceExtension", "3.
|
|
215
|
-
pod "Netmera/NotificationContentExtension", "3.
|
|
213
|
+
pod "Netmera", "3.23.1-WithoutDependency"
|
|
214
|
+
pod "Netmera/NotificationServiceExtension", "3.23.1-WithoutDependency"
|
|
215
|
+
pod "Netmera/NotificationContentExtension", "3.23.1-WithoutDependency"
|
|
216
216
|
```
|
|
217
217
|
|
|
218
218
|
5. In order to use the widget URL callback, add these methods to between `@implementation AppDelegate` and `@end`.
|
|
@@ -336,7 +336,18 @@ const updateUser = () => {
|
|
|
336
336
|
user.surname = <surname>;
|
|
337
337
|
user.msisdn = <msisdn>;
|
|
338
338
|
user.gender = <gender>;
|
|
339
|
+
|
|
340
|
+
// User update async
|
|
341
|
+
Netmera.updateUser(user)
|
|
342
|
+
|
|
343
|
+
// User update sync
|
|
339
344
|
Netmera.updateUser(user)
|
|
345
|
+
.then(() => {
|
|
346
|
+
console.log('User updated successfully!');
|
|
347
|
+
})
|
|
348
|
+
.catch(error => {
|
|
349
|
+
console.log(error.code, error.message);
|
|
350
|
+
});
|
|
340
351
|
}
|
|
341
352
|
```
|
|
342
353
|
|
|
@@ -364,6 +375,18 @@ You can send your events as follows. For more examples, please see the [example
|
|
|
364
375
|
}
|
|
365
376
|
```
|
|
366
377
|
|
|
378
|
+
##### Deeplink
|
|
379
|
+
|
|
380
|
+
In order to manage your deeplinks, use the following method instead of `Linking.getInitialURL`
|
|
381
|
+
|
|
382
|
+
```
|
|
383
|
+
Netmera.getInitialURL(url => {
|
|
384
|
+
console.log(url);
|
|
385
|
+
});
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
You can use other `Linking` methods as before
|
|
389
|
+
|
|
367
390
|
##### Widget URL Callback
|
|
368
391
|
|
|
369
392
|
In order to use the widget URL callback, use `onWidgetUrlTriggered` method as follows.
|
package/RNNetmera.podspec
CHANGED
package/android/build.gradle
CHANGED
|
@@ -4,7 +4,7 @@ android {
|
|
|
4
4
|
compileSdk 33
|
|
5
5
|
|
|
6
6
|
defaultConfig {
|
|
7
|
-
minSdkVersion
|
|
7
|
+
minSdkVersion 21
|
|
8
8
|
targetSdkVersion 33
|
|
9
9
|
versionCode 1
|
|
10
10
|
versionName "1.0"
|
|
@@ -15,8 +15,8 @@ android {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
dependencies {
|
|
18
|
-
implementation 'com.netmera:nmcore:3.
|
|
19
|
-
implementation 'com.netmera:nmfcm:3.
|
|
18
|
+
implementation 'com.netmera:nmcore:3.12.0'
|
|
19
|
+
implementation 'com.netmera:nmfcm:3.12.0'
|
|
20
20
|
implementation 'com.netmera:nmhms:3.11.0'
|
|
21
21
|
implementation 'com.facebook.react:react-native:+'
|
|
22
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.
|
|
26
|
+
headerValues.put("X-netmera-frameworkV", "1.7.0");
|
|
27
27
|
Netmera.setNetmeraHeaders(headerValues);
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -30,6 +30,7 @@ import com.netmera.callbacks.NMCategoryPreferenceFetchCallback;
|
|
|
30
30
|
import com.netmera.callbacks.NMCategoryPreferenceSetCallback;
|
|
31
31
|
import com.netmera.callbacks.NMFetchCouponsResultListener;
|
|
32
32
|
import com.netmera.callbacks.NMInboxCountResultListener;
|
|
33
|
+
import com.netmera.callbacks.NMUpdateUserListener;
|
|
33
34
|
import com.netmera.data.NMCategoryPreference;
|
|
34
35
|
import com.netmera.data.NMCouponDetail;
|
|
35
36
|
import com.netmera.data.NMInboxStatusCount;
|
|
@@ -70,6 +71,9 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
70
71
|
private static final String ERROR_MESSAGE_SET_CATEGORY_PREFERENCE = "Error occurred while setting user category preference list.";
|
|
71
72
|
private static final String ERROR_CODE_COUPON_FETCH = "2026";
|
|
72
73
|
private static final String ERROR_MESSAGE_COUPON_FETCH = "Error occurred while fetching coupons.";
|
|
74
|
+
private static final String ERROR_CODE_UPDATE_USER = "2027";
|
|
75
|
+
private static final String ERROR_MESSAGE_UPDATE_USER = "Error occurred while updating user. Reason: ";
|
|
76
|
+
|
|
73
77
|
|
|
74
78
|
public static ReactApplicationContext reactContext;
|
|
75
79
|
private NetmeraInbox netmeraInbox;
|
|
@@ -294,7 +298,7 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
294
298
|
}
|
|
295
299
|
|
|
296
300
|
@ReactMethod
|
|
297
|
-
public void updateUser(ReadableMap readableMap) {
|
|
301
|
+
public void updateUser(ReadableMap readableMap, final Promise promise) {
|
|
298
302
|
Map userMap = RNNetmeraUtil.toMap(readableMap);
|
|
299
303
|
userMap.values().removeAll(Collections.singleton(null));
|
|
300
304
|
RNNetmeraUser netmeraUser = new RNNetmeraUser();
|
|
@@ -315,7 +319,17 @@ public class RNNetmeraModule extends ReactContextBaseJavaModule {
|
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
netmeraUser.setUserParameters(userMap);
|
|
318
|
-
Netmera.updateUser(netmeraUser)
|
|
322
|
+
Netmera.updateUser(netmeraUser, new NMUpdateUserListener() {
|
|
323
|
+
@Override
|
|
324
|
+
public void onSuccess() {
|
|
325
|
+
promise.resolve(null);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
@Override
|
|
329
|
+
public void onFailure(@Nullable String s) {
|
|
330
|
+
promise.reject(ERROR_CODE_UPDATE_USER, ERROR_MESSAGE_UPDATE_USER + s);
|
|
331
|
+
}
|
|
332
|
+
});
|
|
319
333
|
}
|
|
320
334
|
|
|
321
335
|
@ReactMethod
|
package/ios/RNNetmera.m
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
// RNNetmera.m
|
|
3
|
-
// Netmera SDK
|
|
4
3
|
//
|
|
5
|
-
// Created by
|
|
4
|
+
// Created by Initial Code
|
|
6
5
|
// Copyright © 2019 Netmera. All rights reserved.
|
|
7
6
|
//
|
|
8
7
|
|
|
@@ -12,6 +11,7 @@
|
|
|
12
11
|
#import "RNNetmeraUtils.h"
|
|
13
12
|
#import "RNNetmeraCategoryObject.h"
|
|
14
13
|
#import <Netmera/Netmera.h>
|
|
14
|
+
#import <RNNetmera/RNNetmeraRCTEventEmitter.h>
|
|
15
15
|
|
|
16
16
|
NSString *const ERROR_CODE_INBOX = @"2016";
|
|
17
17
|
NSString *const ERROR_MESSAGE_INBOX = @"There was a problem fetching inbox";
|
|
@@ -33,6 +33,8 @@ 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
34
|
NSString *const ERROR_CODE_COUPON_FETCH = @"2026";
|
|
35
35
|
NSString *const ERROR_MESSAGE_COUPON_FETCH = @"Error occurred while fetching coupons.";
|
|
36
|
+
NSString *const ERROR_CODE_UPDATE_USER = @"2027";
|
|
37
|
+
NSString *const ERROR_MESSAGE_UPDATE_USER = @"Error occurred while updating user. Reason: ";
|
|
36
38
|
|
|
37
39
|
@implementation RNNetmera
|
|
38
40
|
|
|
@@ -44,11 +46,16 @@ NSString *const ERROR_MESSAGE_COUPON_FETCH = @"Error occurred while fetching cou
|
|
|
44
46
|
[Netmera start];
|
|
45
47
|
[Netmera setAPIKey:apiKey];
|
|
46
48
|
[self setNetmeraHeaders];
|
|
49
|
+
[Netmera setDeeplinkCallback:^(NSURL * _Nullable url, NetmeraPushObject * _Nullable pushObject) {
|
|
50
|
+
if (url != nil) {
|
|
51
|
+
[RNNetmeraRCTEventEmitter onDeeplinkTriggered:url];
|
|
52
|
+
}
|
|
53
|
+
}];
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
+ (void)setNetmeraHeaders {
|
|
50
57
|
[Netmera setFramework:@"react"];
|
|
51
|
-
[Netmera setFrameworkVersion:@"1.
|
|
58
|
+
[Netmera setFrameworkVersion:@"1.7.0"];
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
+ (void)setPushDelegate:(NSObject<NetmeraPushDelegate> *)delegate {
|
|
@@ -267,7 +274,9 @@ RCT_EXPORT_METHOD(sendEvent:(NSDictionary *)eventDictionary) {
|
|
|
267
274
|
[Netmera sendEvent:event];
|
|
268
275
|
}
|
|
269
276
|
|
|
270
|
-
RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userDictionary
|
|
277
|
+
RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userDictionary
|
|
278
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
279
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
271
280
|
NSMutableDictionary *userMutableDictionary = [userDictionary mutableCopy];
|
|
272
281
|
NSArray *keysForNullValues = [userMutableDictionary allKeysForObject:[NSNull null]];
|
|
273
282
|
[userMutableDictionary removeObjectsForKeys:keysForNullValues];
|
|
@@ -281,7 +290,20 @@ RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userDictionary) {
|
|
|
281
290
|
[userMutableDictionary removeObjectForKey:@"msisdn"];
|
|
282
291
|
|
|
283
292
|
user.userParameters = userMutableDictionary;
|
|
284
|
-
[Netmera updateUser:user
|
|
293
|
+
[Netmera updateUser:user completion:^(BOOL isSuccess, NSError * _Nullable error) {
|
|
294
|
+
if (error != nil) {
|
|
295
|
+
NSString* errorMessage;
|
|
296
|
+
if (error.userInfo[@"com.netmera.response.object"]) {
|
|
297
|
+
NSDictionary *errorData = error.userInfo[@"com.netmera.response.object"];
|
|
298
|
+
errorMessage = errorData[@"error"];
|
|
299
|
+
} else {
|
|
300
|
+
errorMessage = nil;
|
|
301
|
+
}
|
|
302
|
+
reject(ERROR_CODE_UPDATE_USER, [NSString stringWithFormat:@"%@%@", ERROR_MESSAGE_UPDATE_USER, errorMessage], nil);
|
|
303
|
+
} else {
|
|
304
|
+
resolve(nil);
|
|
305
|
+
}
|
|
306
|
+
}];
|
|
285
307
|
}
|
|
286
308
|
|
|
287
309
|
RCT_EXPORT_METHOD(setApiKey:(NSString *)apiKey) {
|
|
@@ -392,6 +414,11 @@ RCT_EXPORT_METHOD(updateAll:(NSInteger)inboxStatus
|
|
|
392
414
|
}
|
|
393
415
|
}
|
|
394
416
|
|
|
417
|
+
RCT_EXPORT_METHOD(getInitialURL:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
418
|
+
NSURL *url = [RNNetmeraRCTEventEmitter getInitialUrl];
|
|
419
|
+
resolve(url.absoluteString);
|
|
420
|
+
}
|
|
421
|
+
|
|
395
422
|
RCT_EXPORT_METHOD(getInboxCountForStatus:(NSDictionary *) filterDictionary
|
|
396
423
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
397
424
|
rejecter: (RCTPromiseRejectBlock)reject) {
|
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
|
|
12
12
|
@interface RNNetmeraRCTEventEmitter : RCTEventEmitter <RCTBridgeModule>
|
|
13
13
|
|
|
14
|
+
+(NSURL *) getInitialUrl;
|
|
15
|
+
+(void) handleOpenURL:(NSURL *)url forPushObject:(NetmeraPushObject *)object;
|
|
16
|
+
+(void) onDeeplinkTriggered:(NSURL *)url;
|
|
14
17
|
+(void) onPushRegister:(NSDictionary*)dict;
|
|
15
18
|
+(void) onPushReceive:(NSDictionary*)dict;
|
|
16
19
|
+(void) onPushDismiss:(NSDictionary*)dict;
|
|
17
20
|
+(void) onPushOpen:(NSDictionary *)dict;
|
|
18
|
-
+(void) handleOpenURL:(NSURL *)url forPushObject:(NetmeraPushObject *)object;
|
|
19
21
|
|
|
20
22
|
@end
|
|
21
23
|
|
|
@@ -13,6 +13,7 @@ RCT_EXPORT_MODULE();
|
|
|
13
13
|
|
|
14
14
|
bool isReactBridgeInitialized;
|
|
15
15
|
|
|
16
|
+
NSURL* waitingDeeplink = nil;
|
|
16
17
|
NSDictionary* waitingOnPushRegister = nil;
|
|
17
18
|
NSDictionary* waitingOnPushReceive = nil;
|
|
18
19
|
NSDictionary* waitingOnPushOpen = nil;
|
|
@@ -68,6 +69,10 @@ NSDictionary* waitingOnPushDismiss = nil;
|
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
+ (NSURL * _Nullable)getInitialUrl {
|
|
73
|
+
return waitingDeeplink;
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
+ (void)handleOpenURL:(NSURL *)url forPushObject:(NetmeraPushObject *)object {
|
|
72
77
|
if (object.pushType == NetmeraPushTypeWebWidget) {
|
|
73
78
|
NSDictionary* urlDictionary = @{@"url" : url.absoluteString};
|
|
@@ -75,6 +80,12 @@ NSDictionary* waitingOnPushDismiss = nil;
|
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
|
|
83
|
+
+ (void)onDeeplinkTriggered:(NSURL *)url {
|
|
84
|
+
if (!isReactBridgeInitialized) {
|
|
85
|
+
waitingDeeplink = url;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
+ (void)onPushRegister:(NSDictionary *)body {
|
|
79
90
|
NSData *deviceToken = body[@"pushToken"];
|
|
80
91
|
const unsigned char *bytes = deviceToken.bytes;
|
package/package.json
CHANGED
package/src/Netmera.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import {
|
|
6
6
|
AppRegistry,
|
|
7
7
|
DeviceEventEmitter,
|
|
8
|
+
Linking,
|
|
8
9
|
NativeEventEmitter,
|
|
9
10
|
NativeModules,
|
|
10
11
|
NativeModulesStatic,
|
|
@@ -19,7 +20,7 @@ import NMInboxStatusCountFilter from "./models/NMInboxStatusCountFilter";
|
|
|
19
20
|
import NMCategoryPreference from "./models/NMCategoryPreference";
|
|
20
21
|
import { NMInboxStatus } from "./models/NMInboxStatus";
|
|
21
22
|
import NetmeraCouponObject from "./models/NetmeraCouponObject";
|
|
22
|
-
import { isAndroid } from "./utils/DeviceUtils";
|
|
23
|
+
import { isAndroid, isIos } from "./utils/DeviceUtils";
|
|
23
24
|
|
|
24
25
|
const { RNNetmera, RNNetmeraRCTEventEmitter }: NativeModulesStatic =
|
|
25
26
|
NativeModules;
|
|
@@ -201,8 +202,8 @@ export default class Netmera {
|
|
|
201
202
|
RNNetmera.sendEvent(event);
|
|
202
203
|
};
|
|
203
204
|
|
|
204
|
-
static updateUser = (user: NetmeraUser) => {
|
|
205
|
-
RNNetmera.updateUser(user);
|
|
205
|
+
static updateUser = (user: NetmeraUser): Promise<void> => {
|
|
206
|
+
return RNNetmera.updateUser(user);
|
|
206
207
|
};
|
|
207
208
|
|
|
208
209
|
static updateAll = (inboxStatus: number) => {
|
|
@@ -282,4 +283,12 @@ export default class Netmera {
|
|
|
282
283
|
static isNetmeraRemoteMessage(data?: { [key: string]: string }): boolean {
|
|
283
284
|
return isAndroid() && data != undefined && data.hasOwnProperty("_nm");
|
|
284
285
|
}
|
|
286
|
+
|
|
287
|
+
static getInitialURL = async () => {
|
|
288
|
+
if (isIos()) {
|
|
289
|
+
return RNNetmera.getInitialURL();
|
|
290
|
+
} else {
|
|
291
|
+
return Linking.getInitialURL();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
285
294
|
}
|