react-native-netmera 1.3.4 → 1.3.8
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 +473 -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/00a1a2a97b81c133eb73f4c946b323aa/classes/classes.dex +0 -0
- package/android/build/.transforms/{1cc655d17744898d5287444bc3b54ccd.bin → 00a1a2a97b81c133eb73f4c946b323aa.bin} +0 -0
- package/android/build/.transforms/8b103fc7545c9799a16ff009dc2ead52/classes/classes.dex +0 -0
- package/android/build/.transforms/{1d7e2a596c5a01e1599ed8d99d8fed25.bin → 8b103fc7545c9799a16ff009dc2ead52.bin} +0 -0
- package/android/build/.transforms/9e086edd0cadc1c3e325107cef1d09ca/classes/classes.dex +0 -0
- package/android/build/.transforms/{6bd284ae922673d08694a1221c01809c.bin → 9e086edd0cadc1c3e325107cef1d09ca.bin} +0 -0
- package/android/build/.transforms/b0d220ccd1945e73ed321c4b96bb37de/classes/classes.dex +0 -0
- package/android/build/.transforms/{a8f21d984467d686c5d11cdc3f508ab2.bin → b0d220ccd1945e73ed321c4b96bb37de.bin} +0 -0
- package/android/build/.transforms/f70db9a523a6c7b9af14929671f6c09b/classes/classes.dex +0 -0
- package/android/build/.transforms/{ae3b3ad311ea4fe5b0c3652f1d5b8a07.bin → f70db9a523a6c7b9af14929671f6c09b.bin} +0 -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 +3626 -383
- package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +1 -1
- 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 +2726 -11
- package/android/build.gradle +6 -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 +116 -0
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraModule.java +146 -17
- package/android/src/main/java/com/netmera/reactnativesdk/RNNetmeraPushBroadcastReceiver.java +21 -37
- 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/RNNetmeraEvent.m +5 -1
- package/ios/RNNetmeraRCTEventEmitter.h +4 -3
- package/ios/RNNetmeraRCTEventEmitter.m +9 -5
- package/ios/RNNetmeraUtils.m +45 -14
- package/package.json +1 -1
- package/android/build/.transforms/1cc655d17744898d5287444bc3b54ccd/classes/classes.dex +0 -0
- package/android/build/.transforms/1d7e2a596c5a01e1599ed8d99d8fed25/classes/classes.dex +0 -0
- package/android/build/.transforms/6bd284ae922673d08694a1221c01809c/classes/classes.dex +0 -0
- package/android/build/.transforms/a8f21d984467d686c5d11cdc3f508ab2/classes/classes.dex +0 -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/cc45f1af54894b49e3ec8f6b5a05a8d7.bin +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
# Netmera React Native SDK
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
NETMERA is a Mobile Application Engagement Platform. We offer a series of development tools and app communication features to help your mobile business ignite and soar.
|
|
3
4
|
|
|
4
|
-
##
|
|
5
|
+
## Installation
|
|
5
6
|
|
|
6
7
|
`$ npm install react-native-netmera --save`
|
|
7
8
|
|
|
@@ -17,28 +18,483 @@
|
|
|
17
18
|
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
|
18
19
|
2. Go to `node_modules` ➜ `react-native-netmera` and add `RNNetmera.xcodeproj`
|
|
19
20
|
3. In XCode, in the project navigator, select your project. Add `libRNNetmera.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
|
20
|
-
4. Run your project (`Cmd+R`)
|
|
21
|
+
4. Run your project (`Cmd+R`)
|
|
21
22
|
|
|
22
23
|
#### Android
|
|
23
24
|
|
|
24
25
|
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
- Add `import com.netmera.reactnativesdk.RNNetmeraPackage;` to the imports at the top of the file
|
|
27
|
+
- Add `new RNNetmeraPackage()` to the list returned by the `getPackages()` method
|
|
27
28
|
2. Append the following lines to `android/settings.gradle`:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
```
|
|
30
|
+
include ':react-native-netmera'
|
|
31
|
+
project(':react-native-netmera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-netmera/android')
|
|
32
|
+
```
|
|
32
33
|
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
```
|
|
35
|
+
compile project(':react-native-netmera')
|
|
36
|
+
```
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
import {Netmera} from 'react-native-netmera';
|
|
38
|
+
For both native sides(Android & iOS) you don't have to include extra Netmera SDK libraries.
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
### Setup - Android Part
|
|
41
|
+
|
|
42
|
+
1) Create and register your app in [Firebase console](https://firebase.google.com/).
|
|
43
|
+
|
|
44
|
+
2) Download `google-services.json` file and place it into android/app/ folder.
|
|
45
|
+
|
|
46
|
+
3) In your project's build gradle file, add the following dependency.
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
buildscript {
|
|
50
|
+
repositories {
|
|
51
|
+
google()
|
|
52
|
+
jcenter()
|
|
53
|
+
maven {url 'http://developer.huawei.com/repo/'}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
dependencies {
|
|
57
|
+
classpath 'com.android.tools.build:gradle:4.0.2'
|
|
58
|
+
classpath 'com.google.gms:google-services:4.3.10'
|
|
59
|
+
classpath 'com.huawei.agconnect:agcp:1.6.3.300'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
allprojects {
|
|
64
|
+
repositories {
|
|
65
|
+
google()
|
|
66
|
+
jcenter()
|
|
67
|
+
maven { url 'https://maven.google.com'}
|
|
68
|
+
maven {url 'http://developer.huawei.com/repo/'}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
4) In your app's build gradle file, add the following dependency.
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
dependencies {
|
|
78
|
+
|
|
79
|
+
implementation 'androidx.core:core:1.1.0'
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
5) Add the following into the bottom of app's buid.gradle file
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
apply plugin: 'com.google.gms.google-services'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
6) Create an application class as shown below.
|
|
91
|
+
|
|
92
|
+
- Initialize Netmera SDK in your Application class.
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
public class MainApplication extends Application {
|
|
96
|
+
|
|
97
|
+
@Override
|
|
98
|
+
public void onCreate() {
|
|
99
|
+
super.onCreate();
|
|
100
|
+
RNNetmeraConfiguration netmeraConfiguration = new RNNetmeraConfiguration.Builder()
|
|
101
|
+
.firebaseSenderId(<YOUR GCM SENDER ID>)
|
|
102
|
+
.apiKey(<YOUR NETMERA API KEY>) // This is for enabling Netmera logs.
|
|
103
|
+
.logging(true)
|
|
104
|
+
.build(this);
|
|
105
|
+
RNNetmera.initNetmera(netmeraConfiguration);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
43
108
|
```
|
|
109
|
+
|
|
110
|
+
7) Create a new `NetmeraPushHeadlessTask.js` inside your React Native project.
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
export const onPushRegister = async (message) => {
|
|
114
|
+
console.log("onPushRegister: ", message);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const onPushReceive = async (message) => {
|
|
118
|
+
console.log("onPushReceive: ", message);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const onPushOpen = async (message) => {
|
|
122
|
+
console.log("onPushOpen: ", message);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const onPushDismiss = async (message) => {
|
|
126
|
+
console.log("onPushDismiss: ", message);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const onPushButtonClicked = async (message) => {
|
|
130
|
+
console.log("onPushButtonClicked: ", message);
|
|
131
|
+
};
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
8) Init `NetmeraBroadcastReceiver` inside your `index.js` file.
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
import { onPushButtonClicked,
|
|
138
|
+
onPushDismiss,
|
|
139
|
+
onPushOpen,
|
|
140
|
+
onPushReceive,
|
|
141
|
+
onPushRegister
|
|
142
|
+
} from "./NetmeraPushHeadlessTask";
|
|
143
|
+
|
|
144
|
+
Netmera.initBroadcastReceiver(
|
|
145
|
+
onPushRegister,
|
|
146
|
+
onPushReceive,
|
|
147
|
+
onPushOpen,
|
|
148
|
+
onPushDismiss,
|
|
149
|
+
onPushButtonClicked
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
// This should be called after Netmera.initBroadcastReceiver method.
|
|
153
|
+
AppRegistry.registerComponent(appName, () => App);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Setup - iOS Part
|
|
157
|
+
|
|
158
|
+
1) Navigate to ios folder in your terminal and run the following command.
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
$ pod install
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
2) If you want to use Android alike message sending from iOS to react native please consider shaping your AppDelegate class as following.
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
#import "AppDelegate.h"
|
|
168
|
+
|
|
169
|
+
#import <React/RCTBridge.h>
|
|
170
|
+
#import <React/RCTBundleURLProvider.h>
|
|
171
|
+
#import <React/RCTRootView.h>
|
|
172
|
+
#import <RNNetmera/RNNetmeraRCTEventEmitter.h>
|
|
173
|
+
#import <RNNetmera/RNNetmeraUtils.h>
|
|
174
|
+
#import <RNNetmera/RNNetmera.h>
|
|
175
|
+
|
|
176
|
+
@implementation AppDelegate
|
|
177
|
+
|
|
178
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
179
|
+
{
|
|
180
|
+
|
|
181
|
+
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
|
|
182
|
+
|
|
183
|
+
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
|
184
|
+
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
|
|
185
|
+
moduleName:@"example"
|
|
186
|
+
initialProperties:nil];
|
|
187
|
+
|
|
188
|
+
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
|
|
189
|
+
|
|
190
|
+
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
191
|
+
UIViewController *rootViewController = [UIViewController new];
|
|
192
|
+
rootViewController.view = rootView;
|
|
193
|
+
self.window.rootViewController = rootViewController;
|
|
194
|
+
[self.window makeKeyAndVisible];
|
|
195
|
+
|
|
196
|
+
[RNNetmera logging: YES];
|
|
197
|
+
[RNNetmera initNetmera:@"<apiKey>"];
|
|
198
|
+
[RNNetmera requestPushNotificationAuthorization];
|
|
199
|
+
[RNNetmera setPushDelegate:self];
|
|
200
|
+
return YES;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
|
|
204
|
+
{
|
|
205
|
+
#if DEBUG
|
|
206
|
+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
|
|
207
|
+
#else
|
|
208
|
+
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
209
|
+
#endif
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// MARK: Push Delegate Methods
|
|
213
|
+
|
|
214
|
+
// Take push payload for Push clicked:
|
|
215
|
+
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
|
|
216
|
+
{
|
|
217
|
+
if ([response.actionIdentifier isEqual:UNNotificationDismissActionIdentifier]) {
|
|
218
|
+
[RNNetmeraRCTEventEmitter onPushDismiss: @{@"userInfo" : response.notification.request.content.userInfo}];
|
|
219
|
+
} else if ([response.actionIdentifier isEqual:UNNotificationDefaultActionIdentifier]) {
|
|
220
|
+
[RNNetmeraRCTEventEmitter onPushOpen: @{@"userInfo" : response.notification.request.content.userInfo}];
|
|
221
|
+
}
|
|
222
|
+
completionHandler();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Take push payload for push Received on application foreground:
|
|
226
|
+
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
|
|
227
|
+
{
|
|
228
|
+
completionHandler(UNNotificationPresentationOptionAlert);
|
|
229
|
+
[RNNetmeraRCTEventEmitter onPushReceive: @{@"userInfo" : notification.request.content.userInfo}];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
233
|
+
{
|
|
234
|
+
if(deviceToken == nil) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
[RNNetmeraRCTEventEmitter onPushRegister: @{@"pushToken" : deviceToken}];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@end
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
For example if you trigger `[RNNetmeraRCTEventEmitter onPushReceive: @{@"userInfo" : notification.request.content.userInfo}]` from AppDelegate, in the react native part the following method will be triggered.
|
|
244
|
+
```
|
|
245
|
+
export const onPushReceive = async (message) => {
|
|
246
|
+
console.log("onPushReceive: ", message);
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
Please take a look at `Setup-Android part 7`
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
### Calling React Native methods
|
|
253
|
+
|
|
254
|
+
##### Update User Example
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
updateUser() {
|
|
258
|
+
const user = new NetmeraUser();
|
|
259
|
+
user.userId = <userId>;
|
|
260
|
+
user.name = <name>;
|
|
261
|
+
user.surname = <surname>;
|
|
262
|
+
user.msisdn = <msisdn>;
|
|
263
|
+
user.gender = <gender>;
|
|
264
|
+
Netmera.updateUser(user)
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
##### Sending Event Examples
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
void sendLoginEvent() {
|
|
272
|
+
const loginEvent = new LoginEvent();
|
|
273
|
+
loginEvent.setUserId(<userId>);
|
|
274
|
+
Netmera.sendEvent(loginEvent)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
void sendRegisterEvent() {
|
|
278
|
+
const registerEvent = new RegisterEvent();
|
|
279
|
+
Netmera.sendEvent(registerEvent)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
void sendViewCartEvent() {
|
|
283
|
+
const viewCartEvent = new ViewCartEvent();
|
|
284
|
+
viewCartEvent.subTotal = <subTotal>;
|
|
285
|
+
viewCartEvent.itemCount = <itemCount>;
|
|
286
|
+
Netmera.sendEvent(viewCartEvent)
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
void purchaseEvent() {
|
|
290
|
+
const netmeraLineItem = new NetmeraLineItem();
|
|
291
|
+
netmeraLineItem.setBrandId(<brandId>);
|
|
292
|
+
netmeraLineItem.setBrandName(<brandName>);
|
|
293
|
+
netmeraLineItem.setCampaignId(<campaignId>);
|
|
294
|
+
netmeraLineItem.setCategoryIds(<categoryIds>);
|
|
295
|
+
netmeraLineItem.setCategoryNames(<categoryNames>);
|
|
296
|
+
netmeraLineItem.setKeywords(<keywords>);
|
|
297
|
+
netmeraLineItem.setCount(<count>);
|
|
298
|
+
netmeraLineItem.setId(<id>);
|
|
299
|
+
netmeraLineItem.setPrice(<price>);
|
|
300
|
+
|
|
301
|
+
const purchaseEvent = new CustomPurchaseEvent();
|
|
302
|
+
purchaseEvent.coupon = <coupon>;
|
|
303
|
+
purchaseEvent.discount = <discount>;
|
|
304
|
+
purchaseEvent.grandTotal = <grandTotal>;
|
|
305
|
+
purchaseEvent.itemCount = <itemCount>;
|
|
306
|
+
purchaseEvent.paymentMethod = <paymentMethod>;
|
|
307
|
+
purchaseEvent.subTotal = <subTotal>;
|
|
308
|
+
purchaseEvent.shippingCost = <shippingCost>;
|
|
309
|
+
purchaseEvent.purchaseLineItemEvent = [netmeraLineItem, netmeraLineItem];
|
|
310
|
+
purchaseEvent.userName = <userName>;
|
|
311
|
+
Netmera.sendEvent(purchaseEvent)
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
##### Netmera Inbox Examples
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
constructor() {
|
|
318
|
+
super();
|
|
319
|
+
this.state = {
|
|
320
|
+
inbox: [],
|
|
321
|
+
inboxState: Netmera.PUSH_OBJECT_STATUS_ALL,
|
|
322
|
+
countForStatus: 0
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
fetchInbox = async () => {
|
|
327
|
+
try {
|
|
328
|
+
const netmeraInboxFilter = new NetmeraInboxFilter();
|
|
329
|
+
netmeraInboxFilter.status = this.state.inboxState;
|
|
330
|
+
netmeraInboxFilter.pageSize = 2;
|
|
331
|
+
const inbox = await Netmera.fetchInbox(netmeraInboxFilter);
|
|
332
|
+
console.log("inbox", inbox);
|
|
333
|
+
this.setState({inbox: inbox});
|
|
334
|
+
} catch (e) {
|
|
335
|
+
console.log("error", e)
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
fetchNextPage = async () => {
|
|
340
|
+
try {
|
|
341
|
+
const inbox = await Netmera.fetchNextPage();
|
|
342
|
+
this.setState({inbox: inbox});
|
|
343
|
+
console.log("inbox", inbox)
|
|
344
|
+
} catch (e) {
|
|
345
|
+
console.log("error", e)
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
updateAll = async () => {
|
|
350
|
+
if (!this.state.inbox !== undefined) {
|
|
351
|
+
let updateStatus = this.state.inboxState;
|
|
352
|
+
if (updateStatus === Netmera.PUSH_OBJECT_STATUS_ALL) {
|
|
353
|
+
Alert.alert("Error", "Please select different status than all!!")
|
|
354
|
+
console.log("Please select different status than all!!");
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
try {
|
|
359
|
+
Netmera.updateAll(this.state.inboxState).then(() => {
|
|
360
|
+
this.fetchInbox();
|
|
361
|
+
}).catch((error) => {
|
|
362
|
+
console.log("error: " + error)
|
|
363
|
+
})
|
|
364
|
+
} catch (error) {
|
|
365
|
+
console.log("error: " + error)
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
handlePushObject = async () => {
|
|
371
|
+
if (this.state.inbox !== undefined && this.state.inbox.length > 0) {
|
|
372
|
+
Netmera.handlePushObject(this.state.inbox[0].pushId)
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
handleInteractiveAction = async () => {
|
|
377
|
+
if (this.state.inbox !== undefined && this.state.inbox.length > 0) {
|
|
378
|
+
for (let i = 0; i < this.state.inbox.length; i++) {
|
|
379
|
+
const element = this.state.inbox[i];
|
|
380
|
+
if (element.interactiveActions !== undefined && element.interactiveActions.length > 0) {
|
|
381
|
+
const action = JSON.parse(element.interactiveActions)[0]
|
|
382
|
+
Netmera.handleInteractiveAction(action.id);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
countForStatus = async () => {
|
|
390
|
+
try {
|
|
391
|
+
const count = await Netmera.countForStatus(this.state.inboxState);
|
|
392
|
+
this.setState({countForStatus: count})
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.log("error: " + error)
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
inboxUpdateStatus = async () => {
|
|
399
|
+
if (this.state.inboxState === Netmera.PUSH_OBJECT_STATUS_ALL) {
|
|
400
|
+
Alert.alert("Error", "Please select different status than all!!")
|
|
401
|
+
console.log("Please select different status than all!!");
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (this.state.inbox === undefined || this.state.inbox < 2) {
|
|
405
|
+
Alert.alert("Error", "Push objects count is less then 2!")
|
|
406
|
+
console.log("Push objects count is less then 2!");
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
Netmera.inboxUpdateStatus(0, 2, this.state.inboxState).then(() => {
|
|
410
|
+
console.log("2 push object status was changed successfully.")
|
|
411
|
+
}).catch((error) => {
|
|
412
|
+
console.log("error: " + error)
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
updateInboxState = (value) => {
|
|
417
|
+
this.setState({inboxState: value})
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
##### Netmera Inbox Category Examples
|
|
423
|
+
|
|
424
|
+
```
|
|
425
|
+
constructor() {
|
|
426
|
+
super();
|
|
427
|
+
this.state = {
|
|
428
|
+
categories: [],
|
|
429
|
+
categoryState: Netmera.PUSH_OBJECT_STATUS_ALL,
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
fetchCategory = async () => {
|
|
434
|
+
try {
|
|
435
|
+
const netmeraCategoryFilter = new NetmeraCategoryFilter();
|
|
436
|
+
netmeraCategoryFilter.status = this.state.categoryState;
|
|
437
|
+
netmeraCategoryFilter.pageSize = 1;
|
|
438
|
+
const categories = await Netmera.fetchCategory(netmeraCategoryFilter);
|
|
439
|
+
console.log("categories", categories);
|
|
440
|
+
this.setState({categories: categories});
|
|
441
|
+
} catch (e) {
|
|
442
|
+
console.log("error", e)
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
fetchNextCategoryPage = async () => {
|
|
447
|
+
try {
|
|
448
|
+
const categories = await Netmera.fetchNextCategoryPage();
|
|
449
|
+
this.setState({categories: categories});
|
|
450
|
+
console.log("categories", categories)
|
|
451
|
+
} catch (e) {
|
|
452
|
+
console.log("error", e)
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
handlePushObject = async () => {
|
|
457
|
+
if (this.state.categories !== undefined && this.state.categories.length > 0) {
|
|
458
|
+
Netmera.handleLastMessage(this.state.categories[0].categoryName)
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
updateStatusCategories = async () => {
|
|
463
|
+
if (this.state.categoryState === Netmera.PUSH_OBJECT_STATUS_ALL) {
|
|
464
|
+
Alert.alert("Error", "Please select different status than all!!")
|
|
465
|
+
console.log("Please select different status than all!!");
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (this.state.categories === undefined || this.state.categories < 1) {
|
|
469
|
+
Alert.alert("Error", "Category object not found!")
|
|
470
|
+
console.log("Category object not found!");
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const count = this.state.categories.length < 3 ? this.state.categories.length : 2;
|
|
475
|
+
|
|
476
|
+
Netmera.updateStatusByCategories(0, count, this.state.categoryState).then(() => {
|
|
477
|
+
console.log("Category object status was changed successfully.")
|
|
478
|
+
}).catch((error) => {
|
|
479
|
+
console.log("error: " + error)
|
|
480
|
+
});
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
updateCategoryState = (value) => {
|
|
484
|
+
this.setState({categoryState: value})
|
|
485
|
+
};
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
##### Netmera Getting ExternalId (if exists before)
|
|
489
|
+
|
|
490
|
+
```
|
|
491
|
+
Netmera.currentExternalId()
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
For detailed information please explore example folder in the Netmera sdk library.
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
|
|
44
500
|
|
|
Binary file
|
|
Binary file
|
package/android/.idea/gradle.xml
CHANGED
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|