react-native-netmera 1.3.4 → 1.3.5
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 +475 -17
- package/android/.gradle/4.10.1/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
- package/android/.idea/gradle.xml +1 -0
- package/android/build/.transforms/07da1e78aa5e2a23e865850e1fa31195/classes/classes.dex +0 -0
- package/android/build/.transforms/07da1e78aa5e2a23e865850e1fa31195.bin +1 -0
- package/android/build/.transforms/61070ab087fd3e8aaad4987d1cd9aeb2/classes/classes.dex +0 -0
- package/android/build/.transforms/61070ab087fd3e8aaad4987d1cd9aeb2.bin +1 -0
- package/android/build/.transforms/ae3b3ad311ea4fe5b0c3652f1d5b8a07/classes/classes.dex +0 -0
- package/android/build/.transforms/cc45f1af54894b49e3ec8f6b5a05a8d7/classes/classes.dex +0 -0
- package/android/build/.transforms/f58e3ec11746c18253c1a7a566c2609f/classes/classes.dex +0 -0
- package/android/build/.transforms/f58e3ec11746c18253c1a7a566c2609f.bin +1 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +1 -1
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +13 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmera.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraCategoryObject.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraConfiguration$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraConfiguration$Builder.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraConfiguration.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$6.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule$7.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraUtil$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/netmera/reactnativesdk/RNNetmeraUtil.class +0 -0
- package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +1 -1
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +1 -1
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +13 -0
- package/android/build.gradle +4 -6
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmera.java +4 -8
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraCategoryObject.java +56 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraConfiguration.java +128 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +146 -17
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java +16 -38
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraUtil.java +68 -68
- package/index.js +116 -42
- package/ios/RNNetmera.h +6 -0
- package/ios/RNNetmera.m +212 -101
- package/ios/RNNetmeraCategoryObject.h +16 -0
- package/ios/RNNetmeraCategoryObject.m +59 -0
- package/ios/RNNetmeraRCTEventEmitter.h +4 -3
- package/ios/RNNetmeraRCTEventEmitter.m +9 -5
- package/ios/RNNetmeraUtils.m +45 -14
- package/package.json +1 -1
package/ios/RNNetmera.m
CHANGED
|
@@ -10,53 +10,51 @@
|
|
|
10
10
|
#import "RNNetmeraEvent.h"
|
|
11
11
|
#import "RNNetmeraUser.h"
|
|
12
12
|
#import "RNNetmeraUtils.h"
|
|
13
|
+
#import "RNNetmeraCategoryObject.h"
|
|
13
14
|
#import <Netmera/Netmera.h>
|
|
14
15
|
|
|
15
|
-
|
|
16
16
|
NSString *const ERROR_CODE_INBOX = @"2016";
|
|
17
17
|
NSString *const ERROR_MESSAGE_INBOX = @"There was a problem fetching inbox";
|
|
18
18
|
NSString *const ERROR_CODE_NOT_NEXT_PAGE = @"2018";
|
|
19
19
|
NSString *const ERROR_MESSAGE_NOT_NEXT_PAGE = @"Not next page";
|
|
20
20
|
NSString *const ERROR_CODE_UPDATE_STATUS = @"2019";
|
|
21
21
|
NSString *const ERROR_MESSAGE_UPDATE_STATUS = @"There was a problem updating status";
|
|
22
|
+
NSString *const ERROR_CODE_NULL_CATEGORY = @"2020";
|
|
23
|
+
NSString *const ERROR_MESSAGE_NULL_CATEGORY = @"Must call fetchCategory method first";
|
|
24
|
+
NSString *const ERROR_CODE_INVALID_PUSH_OBJECT = @"2021";
|
|
25
|
+
NSString *const ERROR_MESSAGE_INVALID_PUSH_OBJECT = @"Received NetmeraPushObject was not valid.";
|
|
22
26
|
|
|
23
27
|
|
|
24
28
|
@implementation RNNetmera
|
|
25
29
|
|
|
26
|
-
- (instancetype)init
|
|
27
|
-
{
|
|
28
|
-
if (self = [super init]) {
|
|
29
|
-
[Netmera setFrameworkVersion:@"1.3.4true"];
|
|
30
|
-
[Netmera setFramework:@"react"];
|
|
31
|
-
}
|
|
30
|
+
- (instancetype)init {
|
|
32
31
|
return self;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
+ (
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
+ (void)initNetmera:(NSString *)apiKey {
|
|
35
|
+
[Netmera start];
|
|
36
|
+
[Netmera setAPIKey:apiKey];
|
|
37
|
+
[self setNetmeraHeaders];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
+ (void)setNetmeraHeaders {
|
|
41
|
+
[Netmera setFramework:@"react"];
|
|
42
|
+
[Netmera setFrameworkVersion:@"1.3.5"];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
+ (void)setPushDelegate:(NSObject<NetmeraPushDelegate> *)delegate {
|
|
46
|
+
[Netmera setPushDelegate:delegate];
|
|
47
|
+
}
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
[Netmera start];
|
|
50
|
-
[Netmera setAPIKey:apiKey];
|
|
49
|
+
+ (void)requestPushNotificationAuthorization {
|
|
50
|
+
[Netmera requestPushNotificationAuthorizationForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
resolve([Netmera getCurrentExternalId]);
|
|
53
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
54
|
+
return NO;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
{
|
|
57
|
+
+ (void)logging: (BOOL) enabled {
|
|
60
58
|
if(enabled){
|
|
61
59
|
[Netmera setLogLevel:(NetmeraLogLevelDebug)];
|
|
62
60
|
}else{
|
|
@@ -64,55 +62,59 @@ RCT_EXPORT_METHOD(logging:(BOOL *)enabled)
|
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
- (dispatch_queue_t)methodQueue {
|
|
66
|
+
return dispatch_get_main_queue();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
RCT_EXPORT_MODULE()
|
|
70
|
+
|
|
71
|
+
RCT_EXPORT_METHOD(currentExternalId:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
72
|
+
resolve([Netmera getCurrentExternalId]);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
RCT_EXPORT_METHOD(
|
|
73
|
-
|
|
74
|
-
[Netmera requestPushNotificationAuthorizationForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];
|
|
75
|
+
RCT_EXPORT_METHOD(logging:(BOOL *)enabled) {
|
|
76
|
+
[RNNetmera logging:enabled];
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
RCT_EXPORT_METHOD(
|
|
78
|
-
|
|
79
|
+
RCT_EXPORT_METHOD(setBaseUrl:(NSString *)baseUrl) {
|
|
80
|
+
[Netmera setBaseURL:baseUrl];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
RCT_EXPORT_METHOD(requestPushNotificationAuthorization) {
|
|
84
|
+
[Netmera requestPushNotificationAuthorizationForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
RCT_EXPORT_METHOD(requestPermissionsForLocation) {
|
|
79
88
|
[Netmera requestLocationAuthorization];
|
|
80
89
|
}
|
|
81
90
|
|
|
82
|
-
RCT_EXPORT_METHOD(setNetmeraMaxActiveRegions :(NSInteger)maxActiveRegions)
|
|
83
|
-
{
|
|
91
|
+
RCT_EXPORT_METHOD(setNetmeraMaxActiveRegions :(NSInteger)maxActiveRegions) {
|
|
84
92
|
[Netmera setNetmeraMaxActiveRegions:maxActiveRegions];
|
|
85
93
|
}
|
|
86
94
|
|
|
87
|
-
RCT_EXPORT_METHOD(enablePopupPresentation)
|
|
88
|
-
{
|
|
95
|
+
RCT_EXPORT_METHOD(enablePopupPresentation) {
|
|
89
96
|
[Netmera setEnabledPopupPresentation:true];
|
|
90
97
|
}
|
|
91
98
|
|
|
92
|
-
RCT_EXPORT_METHOD(disablePopupPresentation)
|
|
93
|
-
{
|
|
99
|
+
RCT_EXPORT_METHOD(disablePopupPresentation) {
|
|
94
100
|
[Netmera setEnabledPopupPresentation:false];
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
RCT_EXPORT_METHOD(isPushEnabled:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
98
|
-
{
|
|
103
|
+
RCT_EXPORT_METHOD(isPushEnabled:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
99
104
|
resolve(@([Netmera isEnabledReceivingPushNotifications]));
|
|
100
105
|
}
|
|
101
106
|
|
|
102
|
-
RCT_EXPORT_METHOD(enablePush)
|
|
103
|
-
{
|
|
107
|
+
RCT_EXPORT_METHOD(enablePush) {
|
|
104
108
|
[Netmera setEnabledReceivingPushNotifications:true];
|
|
105
109
|
}
|
|
106
110
|
|
|
107
|
-
RCT_EXPORT_METHOD(disablePush)
|
|
108
|
-
{
|
|
111
|
+
RCT_EXPORT_METHOD(disablePush) {
|
|
109
112
|
[Netmera setEnabledReceivingPushNotifications:false];
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
RCT_EXPORT_METHOD(fetchInbox:(NSDictionary *)inboxDictionary
|
|
113
116
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
114
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
115
|
-
{
|
|
117
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
116
118
|
NetmeraInboxFilter *filter = [[NetmeraInboxFilter alloc] init];
|
|
117
119
|
|
|
118
120
|
if(inboxDictionary[@"status"]){
|
|
@@ -134,28 +136,27 @@ RCT_EXPORT_METHOD(fetchInbox:(NSDictionary *)inboxDictionary
|
|
|
134
136
|
|
|
135
137
|
[Netmera fetchInboxUsingFilter:filter
|
|
136
138
|
completion:^(NetmeraInbox *inbox, NSError *error) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
RCT_REMAP_METHOD(fetchNextPage, resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
|
|
151
|
-
{
|
|
139
|
+
if(error) {
|
|
140
|
+
reject(ERROR_CODE_INBOX, ERROR_MESSAGE_INBOX, nil);
|
|
141
|
+
}else{
|
|
142
|
+
self.netmeraInbox = inbox;
|
|
143
|
+
NSMutableArray *array = [[NSMutableArray alloc]init];
|
|
144
|
+
for(NetmeraPushObject *object in self.netmeraInbox.objects){
|
|
145
|
+
[array addObject:[[RNNetmeraUtils shared] dictionaryFromPushObject:object]];
|
|
146
|
+
}
|
|
147
|
+
resolve(array);
|
|
148
|
+
}
|
|
149
|
+
}];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
RCT_REMAP_METHOD(fetchNextPage, resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
152
153
|
[self.netmeraInbox fetchNextPageWithCompletionBlock:^(NSError *error) {
|
|
153
154
|
if(error) {
|
|
154
155
|
reject(ERROR_CODE_NOT_NEXT_PAGE, ERROR_MESSAGE_NOT_NEXT_PAGE, nil);
|
|
155
156
|
}else{
|
|
156
157
|
NSMutableArray *array = [[NSMutableArray alloc]init];
|
|
157
158
|
for(NetmeraPushObject *object in self.netmeraInbox.objects){
|
|
158
|
-
|
|
159
|
+
[array addObject:[[RNNetmeraUtils shared] dictionaryFromPushObject:object]];
|
|
159
160
|
}
|
|
160
161
|
resolve(array);
|
|
161
162
|
}
|
|
@@ -164,8 +165,7 @@ RCT_REMAP_METHOD(fetchNextPage, resolver:(RCTPromiseResolveBlock)resolve rejecte
|
|
|
164
165
|
|
|
165
166
|
RCT_EXPORT_METHOD(countForStatus:(NSInteger *)status
|
|
166
167
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
167
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
168
|
-
{
|
|
168
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
169
169
|
NetmeraInboxStatus netmeraInboxStatus = status;
|
|
170
170
|
NSInteger numOfReadOrUnread = [self.netmeraInbox countForStatus:netmeraInboxStatus];
|
|
171
171
|
resolve([@(numOfReadOrUnread) stringValue]);
|
|
@@ -175,33 +175,47 @@ RCT_EXPORT_METHOD(inboxUpdateStatus:(NSInteger)fromIndex
|
|
|
175
175
|
toIndex:(NSInteger)toIndex
|
|
176
176
|
status:(NSInteger)status
|
|
177
177
|
resolver: (RCTPromiseResolveBlock)resolve
|
|
178
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
179
|
-
{
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
178
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
179
|
+
@try {
|
|
180
|
+
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(fromIndex, toIndex-fromIndex)];
|
|
181
|
+
NetmeraInboxStatus netmeraInboxStatus = status;
|
|
182
|
+
NSArray *pushObjects = [self.netmeraInbox.objects objectsAtIndexes:set];
|
|
183
|
+
[self.netmeraInbox updateStatus:netmeraInboxStatus
|
|
184
|
+
forPushObjects:pushObjects
|
|
185
|
+
completion:^(NSError *error) {
|
|
186
|
+
if(error) {
|
|
187
|
+
reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS, nil);
|
|
188
|
+
}else{
|
|
189
|
+
resolve(nil);
|
|
190
|
+
}
|
|
191
|
+
}];
|
|
192
|
+
|
|
193
|
+
} @catch (NSException *exception) {
|
|
194
|
+
reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS, nil);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
RCT_EXPORT_METHOD(fetchCategory:(NSDictionary *)inboxDictionary
|
|
199
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
200
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
201
|
+
NetmeraInboxCategoryFilter *filter = [RNNetmeraCategoryObject getCategoryObject: inboxDictionary];
|
|
202
|
+
|
|
203
|
+
[Netmera fetchInboxCategoryUsingFilter:filter completion:^(NetmeraInboxCategory *inbox, NSError *error) {
|
|
204
|
+
[self setCategory:inbox error:error resolver:resolve rejecter:reject];
|
|
205
|
+
}];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
RCT_EXPORT_METHOD(fetchNextCategoryPage: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
209
|
+
if (self.netmeraInboxCategory == nil) {
|
|
210
|
+
reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY, nil);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
[self.netmeraInboxCategory fetchNextPageWithCompletionBlock:^(NSError * _Nonnull error) {
|
|
214
|
+
[self setCategory:self.netmeraInboxCategory error:error resolver:resolve rejecter:reject];
|
|
215
|
+
}];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
RCT_EXPORT_METHOD(sendEvent:(NSDictionary *)eventDictionary) {
|
|
205
219
|
NSMutableDictionary *mutableEventDictionary = [eventDictionary mutableCopy];
|
|
206
220
|
RNNetmeraEvent *event = [RNNetmeraEvent event];
|
|
207
221
|
event.netmeraEventKey = mutableEventDictionary[@"code"];
|
|
@@ -210,8 +224,7 @@ RCT_EXPORT_METHOD(sendEvent:(NSDictionary *)eventDictionary)
|
|
|
210
224
|
[Netmera sendEvent:event];
|
|
211
225
|
}
|
|
212
226
|
|
|
213
|
-
RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userDictionary)
|
|
214
|
-
{
|
|
227
|
+
RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userDictionary) {
|
|
215
228
|
NSMutableDictionary *userMutableDictionary = [userDictionary mutableCopy];
|
|
216
229
|
NSArray *keysForNullValues = [userMutableDictionary allKeysForObject:[NSNull null]];
|
|
217
230
|
[userMutableDictionary removeObjectsForKeys:keysForNullValues];
|
|
@@ -228,14 +241,112 @@ RCT_EXPORT_METHOD(updateUser:(NSDictionary *)userDictionary)
|
|
|
228
241
|
[Netmera updateUser:user];
|
|
229
242
|
}
|
|
230
243
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
// handlePushObject
|
|
235
|
-
// handleLastMessage
|
|
236
|
-
// handleInteractiveAction
|
|
237
|
-
// updateStatusByCategories
|
|
238
|
-
// updateAll
|
|
244
|
+
RCT_EXPORT_METHOD(setApiKey:(NSString *)apiKey) {
|
|
245
|
+
[Netmera setAPIKey:apiKey];
|
|
246
|
+
}
|
|
239
247
|
|
|
240
|
-
|
|
248
|
+
RCT_EXPORT_METHOD(handlePushObject:(NSString *)pushId) {
|
|
249
|
+
if (self.netmeraInbox == nil) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
for (int i = 0; i < [self.netmeraInbox.objects count]; i++) {
|
|
254
|
+
if ([pushId isEqualToString: self.netmeraInbox.objects[i].pushId]) {
|
|
255
|
+
[Netmera handlePushObject: self.netmeraInbox.objects[i]];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
RCT_EXPORT_METHOD(handleInteractiveAction:(NSString *)interactiveActionId) {
|
|
261
|
+
if (self.netmeraInbox == nil) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
for (int i = 0; i < [self.netmeraInbox.objects count]; i++) {
|
|
266
|
+
if (self.netmeraInbox.objects[i].interactiveActions != nil) {
|
|
267
|
+
for (int j = 0; j < [self.netmeraInbox.objects[i].interactiveActions count]; j++) {
|
|
268
|
+
NetmeraUserNotificationAction *action = self.netmeraInbox.objects[i].interactiveActions[j];
|
|
269
|
+
if (action != nil && [interactiveActionId isEqualToString: action.interactiveAction.identifier]) {
|
|
270
|
+
[Netmera handleInteractiveAction:action forPushObject:nil];
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
241
277
|
|
|
278
|
+
RCT_EXPORT_METHOD(handleLastMessage: (NSString*) categoryName resolver: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
|
|
279
|
+
if (self.netmeraInboxCategory == nil) {
|
|
280
|
+
reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY, nil);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (categoryName == nil || [categoryName isEqualToString:@""]) {
|
|
284
|
+
reject(ERROR_CODE_INVALID_PUSH_OBJECT, ERROR_MESSAGE_INVALID_PUSH_OBJECT, nil);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
for(NetmeraInboxCategoryObject *category in self.netmeraInboxCategory.objects){
|
|
289
|
+
if([categoryName isEqualToString: category.categoryName]){
|
|
290
|
+
[Netmera handlePushObject:category.lastMessage];
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
RCT_EXPORT_METHOD(updateStatusByCategories:(NSInteger)fromIndex
|
|
297
|
+
toIndex:(NSInteger)toIndex
|
|
298
|
+
status:(NSInteger)status
|
|
299
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
300
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
301
|
+
@try {
|
|
302
|
+
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(fromIndex, toIndex - fromIndex)];
|
|
303
|
+
NSArray *categories = [self.netmeraInboxCategory objects];
|
|
304
|
+
|
|
305
|
+
NSMutableArray *categoryList = [NSMutableArray array];
|
|
306
|
+
for (int i = 0; i < [categories objectsAtIndexes:set].count; i++) {
|
|
307
|
+
[categoryList addObject:[[categories objectAtIndex:i] categoryName]];
|
|
308
|
+
}
|
|
309
|
+
NSArray *categoryNames = [NSArray arrayWithArray:categoryList];
|
|
310
|
+
|
|
311
|
+
NetmeraInboxStatus netmeraInboxStatus = status;
|
|
312
|
+
|
|
313
|
+
[Netmera updateStatus:netmeraInboxStatus
|
|
314
|
+
byCategories:categoryNames
|
|
315
|
+
completion:^(NSError *error) {
|
|
316
|
+
if(error) {
|
|
317
|
+
reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS, nil);
|
|
318
|
+
}else{
|
|
319
|
+
resolve(nil);
|
|
320
|
+
}
|
|
321
|
+
}];
|
|
322
|
+
|
|
323
|
+
} @catch (NSException *exception) {
|
|
324
|
+
reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS, nil);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
RCT_EXPORT_METHOD(updateAll:(NSInteger)inboxStatus
|
|
329
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
330
|
+
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
331
|
+
[Netmera updateStatus:inboxStatus forAllWithCompletion: ^(NSError *error) {
|
|
332
|
+
if (error != nil) {
|
|
333
|
+
reject(ERROR_CODE_UPDATE_STATUS, ERROR_MESSAGE_UPDATE_STATUS, nil);
|
|
334
|
+
} else {
|
|
335
|
+
resolve(@(YES));
|
|
336
|
+
}
|
|
337
|
+
}];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
- (void) setCategory: (NetmeraInboxCategory*)category
|
|
341
|
+
error: (NSError*)error
|
|
342
|
+
resolver: (RCTPromiseResolveBlock)resolve
|
|
343
|
+
rejecter: (RCTPromiseRejectBlock)reject {
|
|
344
|
+
if(error) {
|
|
345
|
+
reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY, nil);
|
|
346
|
+
} else {
|
|
347
|
+
self.netmeraInboxCategory = category;
|
|
348
|
+
resolve([RNNetmeraCategoryObject mapCategoryObjects: self.netmeraInboxCategory.objects]);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
@end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNNetmeraCategoryObject.h
|
|
3
|
+
// Netmera SDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Ensar Bayhan on 06.01.2022.
|
|
6
|
+
// Copyright © 2022 Netmera. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Netmera/Netmera.h>
|
|
10
|
+
|
|
11
|
+
@interface RNNetmeraCategoryObject : NSObject
|
|
12
|
+
|
|
13
|
+
+(NSArray<NSDictionary*>*) mapCategoryObjects: (NSMutableArray<NetmeraInboxCategoryObject *>*) categoryObjects;
|
|
14
|
+
+(NetmeraInboxCategoryFilter*) getCategoryObject: (NSDictionary*) inboxDictionary;
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNNetmeraCategoryObject.m
|
|
3
|
+
// Netmera SDK
|
|
4
|
+
//
|
|
5
|
+
// Created by Ensar Bayhan on 06.01.2022.
|
|
6
|
+
// Copyright © 2022 Netmera. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import "RNNetmeraCategoryObject.h"
|
|
10
|
+
#import "RNNetmeraUtils.h"
|
|
11
|
+
|
|
12
|
+
@implementation RNNetmeraCategoryObject
|
|
13
|
+
|
|
14
|
+
+(NSArray<NSDictionary*>*) mapCategoryObjects: (NSMutableArray<NetmeraInboxCategoryObject *>*) categoryObjects {
|
|
15
|
+
NSMutableArray<NSDictionary*> *categoryObjectList = [[NSMutableArray alloc]init];
|
|
16
|
+
for (int i = 0; i < [categoryObjects count]; i++) {
|
|
17
|
+
[categoryObjectList addObject: [self getCategoryObjectMap:categoryObjects[i]]];
|
|
18
|
+
}
|
|
19
|
+
return categoryObjectList;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
+(NSDictionary*) getCategoryObjectMap:(NetmeraInboxCategoryObject*) categoryObject {
|
|
23
|
+
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
24
|
+
[data setValue:[categoryObject categoryName] forKey:@"categoryName"];
|
|
25
|
+
[data setValue:@([[categoryObject status] readCount]) forKey:@"readCount"];
|
|
26
|
+
[data setValue:@([[categoryObject status] unreadCount]) forKey:@"unreadCount"];
|
|
27
|
+
[data setValue:@([[categoryObject status] deletedCount]) forKey:@"deletedCount"];
|
|
28
|
+
NSDictionary * lastMsg = [[RNNetmeraUtils shared] dictionaryFromPushObject:[categoryObject lastMessage]];
|
|
29
|
+
|
|
30
|
+
NSError *error;
|
|
31
|
+
NSData *dataxx = [NSJSONSerialization dataWithJSONObject:lastMsg options:0 error:&error];
|
|
32
|
+
NSString *jsonStr = [[NSString alloc] initWithData:dataxx encoding:NSUTF8StringEncoding];
|
|
33
|
+
|
|
34
|
+
[data setValue:jsonStr forKey:@"lastMessage"];
|
|
35
|
+
//[data setValue:[jsonData toJSONString] forKey:@"categoryStatus"];
|
|
36
|
+
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
+(NetmeraInboxCategoryFilter*) getCategoryObject: (NSDictionary*) inboxDictionary{
|
|
41
|
+
NetmeraInboxCategoryFilter *filter = [[NetmeraInboxCategoryFilter alloc] init];
|
|
42
|
+
|
|
43
|
+
if(inboxDictionary[@"status"]){
|
|
44
|
+
NetmeraInboxStatus netmeraInboxStatus =[inboxDictionary[@"status"] integerValue];
|
|
45
|
+
filter.status = netmeraInboxStatus;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if(inboxDictionary[@"pageSize"]){
|
|
49
|
+
filter.pageSize = [inboxDictionary[@"pageSize"] intValue];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if(inboxDictionary[@"includeExpiredObjects"]){
|
|
53
|
+
filter.shouldIncludeExpiredObjects = [inboxDictionary[@"includeExpiredObjects"] boolValue];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return filter;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@end
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
@interface RNNetmeraRCTEventEmitter : RCTEventEmitter <RCTBridgeModule>
|
|
13
13
|
|
|
14
|
-
+
|
|
15
|
-
+
|
|
16
|
-
+
|
|
14
|
+
+(void) onPushRegister:(NSDictionary*)dict;
|
|
15
|
+
+(void) onPushReceive:(NSDictionary*)dict;
|
|
16
|
+
+(void) onPushDismiss:(NSDictionary*)dict;
|
|
17
|
+
+(void) onPushOpen:(NSDictionary *)dict;
|
|
17
18
|
|
|
18
19
|
@end
|
|
19
20
|
|
|
@@ -24,7 +24,7 @@ RCT_EXPORT_MODULE();
|
|
|
24
24
|
|
|
25
25
|
- (NSArray<NSString *> *)supportedEvents
|
|
26
26
|
{
|
|
27
|
-
return @[@"onPushReceive", @"onPushOpen", @"onPushRegister"];
|
|
27
|
+
return @[@"onPushReceive", @"onPushOpen", @"onPushRegister", @"onPushDismiss"];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
+ (BOOL)requiresMainQueueSetup
|
|
@@ -47,16 +47,20 @@ RCT_EXPORT_MODULE();
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
+ (void)
|
|
50
|
+
+ (void)onPushRegister:(NSDictionary *)body {
|
|
51
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"onPushRegister" object:nil userInfo:body];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
+ (void)onPushReceive:(NSDictionary *)body {
|
|
51
55
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"onPushReceive" object:nil userInfo:body];
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
+ (void)
|
|
58
|
+
+ (void)onPushOpen:(NSDictionary *)body {
|
|
55
59
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"onPushOpen" object:nil userInfo:body];
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
+ (void)
|
|
59
|
-
[[NSNotificationCenter defaultCenter] postNotificationName:@"
|
|
62
|
+
+ (void)onPushDismiss:(NSDictionary *)body {
|
|
63
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"onPushDismiss" object:nil userInfo:body];
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
@end
|
package/ios/RNNetmeraUtils.m
CHANGED
|
@@ -22,22 +22,53 @@ static RNNetmeraUtils *utils;
|
|
|
22
22
|
|
|
23
23
|
-(NSDictionary *)dictionaryFromPushObject:(NetmeraPushObject *)pushObject{
|
|
24
24
|
NSMutableDictionary *data = [NSMutableDictionary dictionary];
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
|
|
30
|
-
[
|
|
31
|
-
[
|
|
32
|
-
[
|
|
33
|
-
[
|
|
34
|
-
[
|
|
35
|
-
[
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
data[@"pushType"] = [NSNumber numberWithInteger:[pushObject pushType]];
|
|
26
|
+
data[@"pushId"] = [pushObject pushId];
|
|
27
|
+
data[@"pushInstanceId"] = [pushObject pushInstanceId];
|
|
28
|
+
data[@"inboxStatus"] = [NSNumber numberWithInteger:[pushObject inboxStatus]];
|
|
29
|
+
data[@"category"] = [pushObject interactiveCategoryIdentifier];
|
|
30
|
+
data[@"customJson"] = [pushObject customDictionary];
|
|
31
|
+
data[@"deepLink"] = [pushObject action].deeplinkURLString;
|
|
32
|
+
data[@"webPage"] = [[[pushObject dictionaryValue] objectForKey:@"_nm.act"] objectForKey:@"url"];
|
|
33
|
+
data[@"externalId"] = [pushObject externalId];
|
|
34
|
+
data[@"title"] = [[pushObject alert] title];
|
|
35
|
+
data[@"subtitle"] = [[pushObject alert] subtitle];
|
|
36
|
+
data[@"body"] = [[pushObject alert] body];
|
|
37
|
+
data[@"mediaAttachmentURL"] = [[pushObject mediaAttachmentURL] absoluteString];
|
|
38
|
+
data[@"categories"] = [pushObject category];
|
|
39
|
+
data[@"carousel"] = [pushObject carousel];
|
|
40
|
+
|
|
41
|
+
if(pushObject.expirationDate!=nil){
|
|
42
|
+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|
43
|
+
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
44
|
+
data[@"expireTime"] = [dateFormatter stringFromDate:pushObject.expirationDate];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if(pushObject.interactiveActions != nil) {
|
|
49
|
+
NSMutableArray *actions = [[NSMutableArray alloc]init];
|
|
50
|
+
for(int i = 0 ; i < [pushObject.interactiveActions count]; i++) {
|
|
51
|
+
NSMutableDictionary *action = [NSMutableDictionary dictionary];
|
|
52
|
+
action[@"id"] = pushObject.interactiveActions[i].interactiveAction.identifier;
|
|
53
|
+
action[@"text"] = pushObject.interactiveActions[i].interactiveAction.title;
|
|
54
|
+
action[@"act"] = pushObject.interactiveActions[i].actionDictionary;
|
|
55
|
+
action[@"prms"] = pushObject.interactiveActions[i].customDictionary;
|
|
56
|
+
[actions addObject:action];
|
|
57
|
+
}
|
|
58
|
+
NSError *error;
|
|
59
|
+
NSData *dataxx = [NSJSONSerialization dataWithJSONObject:actions options:0 error:&error];
|
|
60
|
+
NSString *jsonStr = [[NSString alloc] initWithData:dataxx encoding:NSUTF8StringEncoding];
|
|
61
|
+
[data setValue:jsonStr forKey:@"interactiveActions"];
|
|
38
62
|
}
|
|
63
|
+
|
|
39
64
|
if(pushObject.sendDate){
|
|
40
|
-
|
|
65
|
+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|
66
|
+
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
|
|
67
|
+
data[@"sendDate"] = [dateFormatter stringFromDate:pushObject.sendDate];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if([[pushObject dictionaryValue] objectForKey:@"_nm.act"] != nil){
|
|
71
|
+
data[@"pushAction"] = [[pushObject dictionaryValue] objectForKey:@"_nm.act"];
|
|
41
72
|
}
|
|
42
73
|
return data;
|
|
43
74
|
}
|