react-native-netmera 1.4.9 → 1.5.0-beta1

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 CHANGED
@@ -8,23 +8,29 @@ NETMERA is a Mobile Application Engagement Platform. We offer a series of develo
8
8
 
9
9
  or
10
10
 
11
- `npm install react-native-netmera`
11
+ `npm install --save react-native-netmera`
12
+
13
+ #### Link Netmera (for RN versions < 0.60)
14
+
15
+ Skip if using React Native version of 0.60 or greater.
16
+
17
+ React Native: `react-native link react-native-netmera`
12
18
 
13
19
  For both native sides (Android & iOS) you don't have to include extra Netmera SDK libraries.
14
20
 
15
21
  ### Setup - Android Part
16
22
 
17
- 1) Create and register your app in [Firebase console](https://firebase.google.com/).
23
+ 1. Create and register your app in [Firebase console](https://firebase.google.com/).
18
24
 
19
- 2) Download `google-services.json` file and place it into android/app/ folder.
25
+ 2. Download `google-services.json` file and place it into android/app/ folder.
20
26
 
21
- 3) In your project's build gradle file, add the following dependencies.
27
+ 3. In your project's build gradle file, add the following dependencies.
22
28
 
23
29
  ```
24
30
  buildscript {
25
31
  repositories {
26
32
  google()
27
- jcenter()
33
+ mavenCentral()
28
34
  maven {url 'https://developer.huawei.com/repo/'}
29
35
  }
30
36
 
@@ -38,7 +44,7 @@ buildscript {
38
44
  allprojects {
39
45
  repositories {
40
46
  google()
41
- jcenter()
47
+ mavenCentral()
42
48
  maven { url 'https://maven.google.com'}
43
49
  maven { url 'https://developer.huawei.com/repo/'}
44
50
  maven { url "https://release.netmera.com/release/android" }
@@ -46,30 +52,31 @@ allprojects {
46
52
  }
47
53
  ```
48
54
 
49
- 4) In your app's build gradle file, add the following dependency.
55
+ 4. In your app's build gradle file, add the following dependency.
50
56
 
51
57
  ```
52
58
 
53
59
  dependencies {
54
60
 
55
- implementation 'androidx.core:core:1.1.0'
61
+ implementation 'androidx.core:core:1.9.0'
62
+
56
63
  }
57
64
  ```
58
65
 
59
- 5) Add the following into the top of app's build.gradle file.
66
+ 5. Add the following into the top of app's build.gradle file.
60
67
 
61
68
  ```
62
69
  apply plugin: 'com.google.gms.google-services'
63
70
  apply plugin: 'com.huawei.agconnect'
64
71
  ```
65
72
 
66
- 6) Create an application class as shown below.
73
+ 6. Create an application class as shown below.
67
74
 
68
75
  - Initialize Netmera SDK in your Application class.
69
76
 
70
- ```
77
+ ```
71
78
  public class MainApplication extends Application {
72
-
79
+
73
80
  @Override
74
81
  public void onCreate() {
75
82
  super.onCreate();
@@ -84,103 +91,28 @@ apply plugin: 'com.huawei.agconnect'
84
91
  }
85
92
  ```
86
93
 
87
- 7) Create a new `NetmeraPushHeadlessTask.js` inside your React Native project.
88
-
89
- ```
90
- export const onPushRegister = async (message) => {
91
- console.log("onPushRegister: ", message);
92
- };
93
-
94
- export const onPushReceive = async (message) => {
95
- console.log("onPushReceive: ", message);
96
- };
97
-
98
- export const onPushOpen = async (message) => {
99
- console.log("onPushOpen: ", message);
100
- };
101
-
102
- export const onPushDismiss = async (message) => {
103
- console.log("onPushDismiss: ", message);
104
- };
94
+ ### Setup - iOS Part
105
95
 
106
- export const onPushButtonClicked = async (message) => {
107
- console.log("onPushButtonClicked: ", message);
108
- };
96
+ 1. Navigate to ios folder in your terminal and run the following command.
109
97
 
110
- export const onCarouselObjectSelected = async (message) => {
111
- console.log("onCarouselObjectSelected: ", message);
112
- };
113
98
  ```
114
-
115
- 8) Init `NetmeraBroadcastReceiver` inside your `index.js` file.
116
-
99
+ $ pod install
117
100
  ```
118
- import {
119
- onCarouselObjectSelected,
120
- onPushButtonClicked,
121
- onPushDismiss,
122
- onPushOpen,
123
- onPushReceive,
124
- onPushRegister
125
- } from "./NetmeraPushHeadlessTask";
126
101
 
127
- Netmera.initBroadcastReceiver(
128
- onPushRegister,
129
- onPushReceive,
130
- onPushOpen,
131
- onPushDismiss,
132
- onPushButtonClicked,
133
- onCarouselObjectSelected
134
- )
135
-
136
- // This should be called after Netmera.initBroadcastReceiver method.
137
- AppRegistry.registerComponent(appName, () => App);
138
- ```
102
+ 2. Download `GoogleService-Info.plist` file from Firebase and place it into ios/ folder.
139
103
 
140
- 9) If you have custom Firebase Messaging integration, please see usage below.
104
+ 3. Enable push notifications for your project
141
105
 
142
- ```
143
- messaging()
144
- .getToken(firebase.app().options.messagingSenderId)
145
- .then(pushToken => {
146
- Netmera.onNetmeraNewToken(pushToken)
147
- })
106
+ 1. If you have not generated a valid push notification certificate yet,
107
+ generate one and then export by following the steps explained in [Configuring Push Notifications section of App Distribution Guide](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns#2947597)
108
+ 2. Export the generated push certificate in .p12 format and upload to Netmera Dashboard.
109
+ 3. Enable Push Notifications capability for your application as explained in [Enable Push Notifications](https://developer.netmera.com/en/IOS/Quick-Start#enable-push-notifications) guide.
110
+ 4. Enable Remote notifications background mode for your application as explained in [Configuring Background Modes](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app#2980038) guide.
148
111
 
149
- messaging().onMessage(async remoteMessage => {
150
- if (Netmera.isNetmeraRemoteMessage(remoteMessage.data)) {
151
- Netmera.onNetmeraFirebasePushMessageReceived(remoteMessage.from, remoteMessage.data)
152
- }
153
- });
154
- ```
112
+ 4. If you want to use Android alike message sending from iOS to react native please consider shaping your AppDelegate class as following.
155
113
 
156
- 10) If you have custom Huawei Messaging integration, please see usage below.
114
+ #### AppDelegate.h
157
115
 
158
- ```
159
- HmsPushInstanceId.getToken("")
160
- .then((result) => {
161
- Netmera.onNetmeraNewToken(result.result)
162
- })
163
-
164
- HmsPushEvent.onRemoteMessageReceived(event => {
165
- const remoteMessage = new RNRemoteMessage(event.msg);
166
- let data = JSON.parse(remoteMessage.getData())
167
- console.log("onRemoteMessageReceived", data)
168
- if (Netmera.isNetmeraRemoteMessage(data)) {
169
- Netmera.onNetmeraHuaweiPushMessageReceived(remoteMessage.getFrom(), data)
170
- }
171
- })
172
- ```
173
-
174
- ### Setup - iOS Part
175
-
176
- 1) Navigate to ios folder in your terminal and run the following command.
177
-
178
- ```
179
- $ pod install
180
- ```
181
-
182
- 2) If you want to use Android alike message sending from iOS to react native please consider shaping your AppDelegate class as following.
183
- - `AppDelegate.h`
184
116
  ```
185
117
  #import <React/RCTBridgeDelegate.h>
186
118
  #import <UIKit/UIKit.h>
@@ -195,18 +127,26 @@ $ pod install
195
127
  @end
196
128
  ```
197
129
 
198
- - `AppDelegate.m`
199
- ```
200
- #import "AppDelegate.h"
130
+ #### AppDelegate.m
201
131
 
132
+ - Add the following to the top of AppDelegate.m file.
133
+
134
+ ```
202
135
  #import <RNNetmera/RNNetmeraRCTEventEmitter.h>
203
136
  #import <RNNetmera/RNNetmeraUtils.h>
204
137
  #import <RNNetmera/RNNetmera.h>
138
+ ```
205
139
 
206
- @implementation AppDelegate
140
+ - Add the following lines into the `didFinishLaunchingWithOptions` method.
141
+
142
+ ```
207
143
 
208
144
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
209
145
  {
146
+ // Add this line to set notification delegate
147
+ [UNUserNotificationCenter currentNotificationCenter].delegate = self;
148
+
149
+ ...
210
150
 
211
151
  // Add these lines to init Netmera
212
152
  [RNNetmera logging: YES]; // This is for enabling Netmera logs.
@@ -214,9 +154,19 @@ $ pod install
214
154
  [RNNetmera requestPushNotificationAuthorization];
215
155
  [RNNetmera setPushDelegate:self];
216
156
  [Netmera setAppGroupName:<YOUR APP GROUP NAME>]; // Set your app group name
217
-
157
+
218
158
  return YES;
219
159
  }
160
+ ```
161
+
162
+ - Add these methods to between `@implementation AppDelegate` and `@end`.
163
+
164
+ ```
165
+ @implementation AppDelegate
166
+
167
+ ...
168
+
169
+ // MARK: Push Delegate Methods
220
170
 
221
171
  // Take push payload for Push clicked:
222
172
  -(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
@@ -247,14 +197,16 @@ $ pod install
247
197
  @end
248
198
 
249
199
  ```
200
+
250
201
  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.
202
+
251
203
  ```
252
204
  export const onPushReceive = async (message) => {
253
205
  console.log("onPushReceive: ", message);
254
206
  };
255
207
  ```
256
208
 
257
- 3) In order to use iOS10 Media Push, follow the instructions in [Netmera Product Hub.](https://developer.netmera.com/en/IOS/Push-Notifications#using-ios10-media-push)
209
+ 4. In order to use iOS10 Media Push, follow the instructions in [Netmera Product Hub.](https://developer.netmera.com/en/IOS/Push-Notifications#using-ios10-media-push) Differently, you should add the pods to the top of the `Podfile` as below.
258
210
 
259
211
  ```
260
212
  // For receiving Media Push, you must add Netmera pods to top of your Podfile.
@@ -263,12 +215,108 @@ export const onPushReceive = async (message) => {
263
215
  pod "Netmera/NotificationContentExtension", "3.14.10-WithoutDependency"
264
216
  ```
265
217
 
218
+ ### Setup - React Native Part
219
+
220
+ 1. Create a new `NetmeraPushHeadlessTask.js` inside your React Native project.
221
+
222
+ ```
223
+ export const onPushRegister = async (message) => {
224
+ console.log("onPushRegister: ", message);
225
+ };
226
+
227
+ export const onPushReceive = async (message) => {
228
+ console.log("onPushReceive: ", message);
229
+ };
230
+
231
+ export const onPushOpen = async (message) => {
232
+ console.log("onPushOpen: ", message);
233
+ };
234
+
235
+ export const onPushDismiss = async (message) => {
236
+ console.log("onPushDismiss: ", message);
237
+ };
238
+
239
+ export const onPushButtonClicked = async (message) => {
240
+ console.log("onPushButtonClicked: ", message);
241
+ };
242
+
243
+ export const onCarouselObjectSelected = async (message) => {
244
+ console.log("onCarouselObjectSelected: ", message);
245
+ };
246
+ ```
247
+
248
+ 2. Init `NetmeraBroadcastReceiver` inside your `index.js` file.
249
+
250
+ ```
251
+ import {
252
+ onCarouselObjectSelected,
253
+ onPushButtonClicked,
254
+ onPushDismiss,
255
+ onPushOpen,
256
+ onPushReceive,
257
+ onPushRegister
258
+ } from "./NetmeraPushHeadlessTask";
259
+
260
+ Netmera.initBroadcastReceiver(
261
+ onPushRegister,
262
+ onPushReceive,
263
+ onPushOpen,
264
+ onPushDismiss,
265
+ onPushButtonClicked,
266
+ onCarouselObjectSelected
267
+ )
268
+
269
+ // This should be called after Netmera.initBroadcastReceiver method.
270
+ AppRegistry.registerComponent(appName, () => App);
271
+ ```
272
+
273
+ 3. If you have custom Firebase Messaging integration, please see usage below.
274
+
275
+ ```
276
+ messaging()
277
+ .getToken(firebase.app().options.messagingSenderId)
278
+ .then(pushToken => {
279
+ Netmera.onNetmeraNewToken(pushToken)
280
+ });
281
+
282
+ messaging().onMessage(async remoteMessage => {
283
+ if (Netmera.isNetmeraRemoteMessage(remoteMessage.data)) {
284
+ Netmera.onNetmeraFirebasePushMessageReceived(remoteMessage.from, remoteMessage.data)
285
+ }
286
+ });
287
+
288
+ messaging().setBackgroundMessageHandler(async (remoteMessage) => {
289
+ if (Netmera.isNetmeraRemoteMessage(remoteMessage.data)) {
290
+ Netmera.onNetmeraFirebasePushMessageReceived(remoteMessage.from, remoteMessage.data)
291
+ }
292
+ });
293
+
294
+ ```
295
+
296
+ 4. If you have custom Huawei Messaging integration, please see usage below.
297
+
298
+ ```
299
+ HmsPushInstanceId.getToken("")
300
+ .then((result) => {
301
+ Netmera.onNetmeraNewToken(result.result)
302
+ })
303
+
304
+ HmsPushEvent.onRemoteMessageReceived(event => {
305
+ const remoteMessage = new RNRemoteMessage(event.msg);
306
+ let data = JSON.parse(remoteMessage.getData())
307
+ console.log("onRemoteMessageReceived", data)
308
+ if (Netmera.isNetmeraRemoteMessage(data)) {
309
+ Netmera.onNetmeraHuaweiPushMessageReceived(remoteMessage.getFrom(), data)
310
+ }
311
+ })
312
+ ```
313
+
266
314
  ### Calling React Native methods
267
315
 
268
316
  ##### Update User Example
269
317
 
270
318
  ```
271
- updateUser() {
319
+ const updateUser = () => {
272
320
  const user = new NetmeraUser();
273
321
  user.userId = <userId>;
274
322
  user.name = <name>;
@@ -276,60 +324,37 @@ updateUser() {
276
324
  user.msisdn = <msisdn>;
277
325
  user.gender = <gender>;
278
326
  Netmera.updateUser(user)
279
- }
327
+ }
280
328
  ```
281
329
 
282
330
  ##### Sending Event Examples
283
331
 
332
+ You can send your events as follows. For more examples, please see the [example project](https://github.com/Netmera/Netmera-React-Native-Example/blob/master/src/Screens/Event.js).
333
+
284
334
  ```
285
- void sendLoginEvent() {
335
+ const sendLoginEvent = () => {
286
336
  const loginEvent = new LoginEvent();
287
337
  loginEvent.setUserId(<userId>);
288
338
  Netmera.sendEvent(loginEvent)
289
339
  }
290
340
 
291
- void sendRegisterEvent() {
341
+ const sendRegisterEvent = () => {
292
342
  const registerEvent = new RegisterEvent();
293
343
  Netmera.sendEvent(registerEvent)
294
344
  }
295
345
 
296
- void sendViewCartEvent() {
346
+ const sendViewCartEvent = () => {
297
347
  const viewCartEvent = new ViewCartEvent();
298
348
  viewCartEvent.subTotal = <subTotal>;
299
349
  viewCartEvent.itemCount = <itemCount>;
300
350
  Netmera.sendEvent(viewCartEvent)
301
351
  }
302
-
303
- void purchaseEvent() {
304
- const netmeraLineItem = new NetmeraLineItem();
305
- netmeraLineItem.setBrandId(<brandId>);
306
- netmeraLineItem.setBrandName(<brandName>);
307
- netmeraLineItem.setCampaignId(<campaignId>);
308
- netmeraLineItem.setCategoryIds(<categoryIds>);
309
- netmeraLineItem.setCategoryNames(<categoryNames>);
310
- netmeraLineItem.setKeywords(<keywords>);
311
- netmeraLineItem.setCount(<count>);
312
- netmeraLineItem.setId(<id>);
313
- netmeraLineItem.setPrice(<price>);
314
-
315
- const purchaseEvent = new CustomPurchaseEvent();
316
- purchaseEvent.coupon = <coupon>;
317
- purchaseEvent.discount = <discount>;
318
- purchaseEvent.grandTotal = <grandTotal>;
319
- purchaseEvent.itemCount = <itemCount>;
320
- purchaseEvent.paymentMethod = <paymentMethod>;
321
- purchaseEvent.subTotal = <subTotal>;
322
- purchaseEvent.shippingCost = <shippingCost>;
323
- purchaseEvent.purchaseLineItemEvent = [netmeraLineItem, netmeraLineItem];
324
- purchaseEvent.userName = <userName>;
325
- Netmera.sendEvent(purchaseEvent)
326
- }
327
352
  ```
328
353
 
329
354
  ##### Push Notification Permissions
330
355
 
331
- If you don't request notification permission at runtime, you can request it by calling the `requestPushNotificationAuthorization()` method.
332
- Note: Notification runtime permissions are required on Android 13 (API 33) or higher.
356
+ If you don't request notification permission at runtime, you can request it by calling the `requestPushNotificationAuthorization()` method.
357
+ Note: Notification runtime permissions are required on Android 13 (API 33) or higher.
333
358
  Therefore, before calling the method, make sure your project targets an API of 33 and above.
334
359
 
335
360
  ```
@@ -338,220 +363,45 @@ Therefore, before calling the method, make sure your project targets an API of 3
338
363
 
339
364
  You can call the `areNotificationsEnabled()` method if you need to know the status of permissions.
340
365
 
341
- ```
366
+ ```
342
367
  await Netmera.areNotificationsEnabled() // Use the enabled status of permission as boolean
343
368
  ```
344
369
 
345
370
  ##### Netmera Inbox Examples
346
371
 
347
- ```
348
- constructor() {
349
- super();
350
- this.state = {
351
- inbox: [],
352
- inboxState: Netmera.PUSH_OBJECT_STATUS_ALL,
353
- countForStatus: 0
354
- }
355
- }
372
+ You can fetch the Netmera inbox as following. For more detailed usage, please see the [example project](https://github.com/Netmera/Netmera-React-Native-Example/blob/master/src/Screens/PushInbox.js).
356
373
 
357
- fetchInbox = async () => {
374
+ ```
375
+ const fetchInbox = async () => {
358
376
  try {
359
377
  const netmeraInboxFilter = new NetmeraInboxFilter();
360
- netmeraInboxFilter.status = this.state.inboxState;
361
- netmeraInboxFilter.pageSize = 2;
378
+ netmeraInboxFilter.status = Netmera.PUSH_OBJECT_STATUS_UNREAD;
379
+ netmeraInboxFilter.pageSize = 2; // Fetch two push object
362
380
  const inbox = await Netmera.fetchInbox(netmeraInboxFilter);
363
381
  console.log("inbox", inbox);
364
- this.setState({inbox: inbox});
365
382
  } catch (e) {
366
383
  console.log("error", e)
367
384
  }
368
- };
369
-
370
- fetchNextPage = async () => {
371
- try {
372
- const inbox = await Netmera.fetchNextPage();
373
- this.setState({inbox: inbox});
374
- console.log("inbox", inbox)
375
- } catch (e) {
376
- console.log("error", e)
377
- }
378
- };
379
-
380
- updateAll = async () => {
381
- if (!this.state.inbox !== undefined) {
382
- let updateStatus = this.state.inboxState;
383
- if (updateStatus === Netmera.PUSH_OBJECT_STATUS_ALL) {
384
- Alert.alert("Error", "Please select different status than all!!")
385
- console.log("Please select different status than all!!");
386
- return;
387
- }
388
-
389
- try {
390
- Netmera.updateAll(this.state.inboxState).then(() => {
391
- this.fetchInbox();
392
- }).catch((error) => {
393
- console.log("error: " + error)
394
- })
395
- } catch (error) {
396
- console.log("error: " + error)
397
- }
398
- }
399
- };
400
-
401
- handlePushObject = async () => {
402
- if (this.state.inbox !== undefined && this.state.inbox.length > 0) {
403
- Netmera.handlePushObject(this.state.inbox[0].pushId)
404
- }
405
- };
406
-
407
- handleInteractiveAction = async () => {
408
- if (this.state.inbox !== undefined && this.state.inbox.length > 0) {
409
- for (let i = 0; i < this.state.inbox.length; i++) {
410
- const element = this.state.inbox[i];
411
- if (element.interactiveActions !== undefined && element.interactiveActions.length > 0) {
412
- const action = JSON.parse(element.interactiveActions)[0]
413
- Netmera.handleInteractiveAction(action.id);
414
- return;
415
- }
416
- }
417
- }
418
- };
419
-
420
- countForStatus = async () => {
421
- try {
422
- const count = await Netmera.countForStatus(this.state.inboxState);
423
- this.setState({countForStatus: count})
424
- } catch (e) {
425
- }
426
- };
427
-
428
- inboxUpdateStatus = async () => {
429
- if (this.state.inboxState === Netmera.PUSH_OBJECT_STATUS_ALL) {
430
- Alert.alert("Error", "Please select different status than all!!")
431
- console.log("Please select different status than all!!");
432
- return;
433
- }
434
- if (this.state.inbox === undefined || this.state.inbox < 2) {
435
- Alert.alert("Error", "Push objects count is less then 2!")
436
- console.log("Push objects count is less then 2!");
437
- return;
438
- }
439
- Netmera.inboxUpdateStatus(0, 2, this.state.inboxState).then(() => {
440
- console.log("2 push object status was changed successfully.")
441
- }).catch((error) => {
442
- console.log("error: " + error)
443
- });
444
- };
445
-
446
- updateInboxState = (value) => {
447
- this.setState({inboxState: value})
448
- };
449
-
450
- inboxCountForStatus = async () => {
451
- try {
452
- const filter = new NMInboxStatusCountFilter();
453
- filter.nmInboxStatus = this.state.inboxState;
454
- filter.includeExpired = true;
455
- const nmInboxStatusCount = await Netmera.getInboxCountForStatus(filter);
456
-
457
- let countStatusText =
458
- "READ: " + nmInboxStatusCount[NMInboxStatus.STATUS_READ] + ", " +
459
- "UNREAD: " + nmInboxStatusCount[NMInboxStatus.STATUS_UNREAD]
460
-
461
- this.setState({countForStatus: countStatusText})
462
- console.log("nmInboxStatusCount: ", countStatusText);
463
- } catch (e) {
464
- console.log("error", e)
465
- }
466
- };
385
+ }
467
386
  ```
468
387
 
469
388
  ##### Netmera Inbox Category Examples
470
389
 
471
- ```
472
- constructor() {
473
- super();
474
- this.state = {
475
- categories: [],
476
- userCategoryPreferences: [],
477
- categoryState: Netmera.PUSH_OBJECT_STATUS_ALL,
478
- }
479
- }
390
+ You can fetch the Netmera category as following. For more detailed usage, please see the [example project](https://github.com/Netmera/Netmera-React-Native-Example/blob/master/src/Screens/Category.js).
480
391
 
481
- fetchCategory = async () => {
392
+ ```
393
+ const fetchCategory = async () => {
482
394
  try {
483
- const netmeraCategoryFilter = new NetmeraCategoryFilter();
484
- netmeraCategoryFilter.status = this.state.categoryState;
485
- netmeraCategoryFilter.pageSize = 1;
486
- const categories = await Netmera.fetchCategory(netmeraCategoryFilter);
395
+ const netmeraCategoryFilter = new NetmeraCategoryFilter()
396
+ netmeraCategoryFilter.status = categoryState
397
+ netmeraCategoryFilter.pageSize = 1 // Fetch one by one
398
+ const categories = await Netmera.fetchCategory(netmeraCategoryFilter)
487
399
  console.log("categories", categories);
488
- this.setState({categories: categories});
400
+ setCategories(categories)
489
401
  } catch (e) {
490
402
  console.log("error", e)
491
403
  }
492
404
  };
493
-
494
- fetchNextCategoryPage = async () => {
495
- try {
496
- const categories = await Netmera.fetchNextCategoryPage();
497
- this.setState({categories: categories});
498
- console.log("categories", categories)
499
- } catch (e) {
500
- console.log("error", e)
501
- }
502
- };
503
-
504
- handlePushObject = async () => {
505
- if (this.state.categories !== undefined && this.state.categories.length > 0) {
506
- Netmera.handleLastMessage(this.state.categories[0].categoryName)
507
- }
508
- };
509
-
510
- updateStatusCategories = async () => {
511
- if (this.state.categoryState === Netmera.PUSH_OBJECT_STATUS_ALL) {
512
- Alert.alert("Error", "Please select different status than all!!")
513
- console.log("Please select different status than all!!");
514
- return;
515
- }
516
- if (this.state.categories === undefined || this.state.categories < 1) {
517
- Alert.alert("Error", "Category object not found!")
518
- console.log("Category object not found!");
519
- return;
520
- }
521
-
522
- const count = this.state.categories.length < 3 ? this.state.categories.length : 2;
523
-
524
- Netmera.updateStatusByCategories(0, count, this.state.categoryState).then(() => {
525
- console.log("Category object status was changed successfully.")
526
- }).catch((error) => {
527
- console.log("error: " + error)
528
- });
529
- };
530
-
531
- updateCategoryState = (value) => {
532
- this.setState({categoryState: value})
533
- };
534
-
535
- getUserCategoryPreferenceList = async () => {
536
- Netmera.getUserCategoryPreferenceList().then((response) => {
537
- this.setState({categories: response})
538
- console.log("User Category Preference List: " + response)
539
- }).catch((error) => {
540
- console.log("error: " + error)
541
- });
542
- };
543
-
544
- setUserCategoryPreference = async (item) => {
545
- Netmera.setUserCategoryPreference(item.categoryId, !item.optInStatus).then(() => {
546
- console.log("Successfully set user category preference list")
547
- setTimeout(() => {
548
- this.getUserCategoryPreferenceList()
549
- }, 500)
550
-
551
- }).catch((error) => {
552
- console.log("error: " + error)
553
- });
554
- };
555
405
  ```
556
406
 
557
407
  ##### Netmera Getting ExternalId (if exists before)
@@ -560,4 +410,13 @@ You can call the `areNotificationsEnabled()` method if you need to know the stat
560
410
  Netmera.currentExternalId()
561
411
  ```
562
412
 
413
+ ##### Netmera Popup Presentation
414
+
415
+ To enable popup presentation, you need to call the `enablePopupPresentation()` method on the page where you want to display the popup.
416
+ Note: To show popup on the app start or everywhere in the app, please add this to `index.js` file.
417
+
418
+ ```
419
+ Netmera.enablePopupPresentation();
420
+ ```
421
+
563
422
  Please explore [our example project](https://github.com/Netmera/Netmera-React-Native-Example) for detailed information.
@@ -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.4.9");
26
+ headerValues.put("X-netmera-frameworkV", "1.5.0-beta1");
27
27
  Netmera.setNetmeraHeaders(headerValues);
28
28
  }
29
29