react-native-netmera 2.0.0-alpha02 → 2.0.0-alpha04

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
@@ -173,8 +173,8 @@ RNNetmera.initNetmera()
173
173
 
174
174
  ```
175
175
  // For receiving Media Push, you must add Netmera pods to top of your Podfile.
176
- pod 'NetmeraNotificationServiceExtension', "4.15.0"
177
- pod "NetmeraNotificationContentExtension", "4.15.0"
176
+ pod 'NetmeraNotificationServiceExtension', "4.17.0"
177
+ pod "NetmeraNotificationContentExtension", "4.17.0"
178
178
  ```
179
179
 
180
180
  7. In order to use the widget URL callback, add these lines into `AppDelegate.swift` file.
@@ -191,12 +191,12 @@ import NetmeraNotification
191
191
  ...
192
192
 
193
193
  extension AppDelegate: NetmeraPushDelegate {
194
- func shouldHandleOpenURL(_ url: URL, for pushObject: NetmeraNotificationCore.NetmeraBasePush) -> Bool {
195
- return false
194
+ func urlOpeningDecision(for url: URL, push: NetmeraNotificationCore.NetmeraBasePush) -> PushDelegateDecision {
195
+ return .sdkHandles
196
196
  }
197
197
 
198
- func handleOpenURL(_ url: URL, for pushObject: NetmeraNotificationCore.NetmeraBasePush) {
199
- RNNetmeraRCTEventEmitter.handleOpenURL(url, forPushObject: pushObject)
198
+ func openURL(_ url: URL, for push: NetmeraNotificationCore.NetmeraBasePush) {
199
+ RNNetmeraRCTEventEmitter.openURL(url, forPushObject: push)
200
200
  }
201
201
  }
202
202
  ```
package/RNNetmera.podspec CHANGED
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
19
19
  s.source_files = "ios/**/*.{h,m,mm,swift}"
20
20
  s.public_header_files = "ios/RNNetmera.h"
21
21
 
22
- netmera_version = '4.15.0'
22
+ netmera_version = '4.17.0'
23
23
 
24
24
  s.dependency "NetmeraAnalytic", netmera_version
25
25
  s.dependency "NetmeraAnalyticAutotracking", netmera_version
@@ -75,7 +75,7 @@ repositories {
75
75
  google()
76
76
  }
77
77
 
78
- def netmeraAndroidVersion = '4.13.3'
78
+ def netmeraAndroidVersion = '4.14.3'
79
79
 
80
80
  def kotlin_version = getExtOrDefault("kotlinVersion")
81
81
 
@@ -20,11 +20,12 @@ class RNNetmeraConfiguration private constructor(
20
20
  val apiKey: String?,
21
21
  val firebaseSenderId: String?,
22
22
  val logging: Boolean,
23
+ private val disableSerializeRule: Boolean,
23
24
  val sslPinKeys: List<String>?
24
25
  ) {
25
26
 
26
27
  fun getNetmeraConfiguration(): NetmeraConfiguration {
27
- val pushCallbacks = nmPushActionCallbacks ?: RNNetmeraPushBroadcastReceiver()
28
+ val pushCallbacks = nmPushActionCallbacks ?: RNNetmeraPushActionCallbacks()
28
29
  val webWidgetCallbacks = nmWebWidgetCallbacks ?: RNNetmeraWebWidgetCallbacks()
29
30
 
30
31
  val builder = NetmeraConfiguration.Builder()
@@ -38,7 +39,7 @@ class RNNetmeraConfiguration private constructor(
38
39
 
39
40
  return builder
40
41
  .logging(logging)
41
- .disableSerializeRule(true)
42
+ .disableSerializeRule(disableSerializeRule)
42
43
  .addProvider(NMFCMProvider())
43
44
  .addProvider(NMHMSProvider())
44
45
  .nmPushActionCallbacks(pushCallbacks)
@@ -56,6 +57,7 @@ class RNNetmeraConfiguration private constructor(
56
57
  private var apiKey: String? = null
57
58
  private var firebaseSenderId: String? = null
58
59
  private var logging: Boolean = false
60
+ private var disableSerializeRule: Boolean = true
59
61
  private var sslPinKeys: List<String>? = null
60
62
 
61
63
  fun nmInAppMessageActionCallbacks(callbacks: NMInAppMessageActionCallbacks) = apply {
@@ -79,6 +81,7 @@ class RNNetmeraConfiguration private constructor(
79
81
  fun firebaseSenderId(firebaseSenderId: String) = apply { this.firebaseSenderId = firebaseSenderId }
80
82
 
81
83
  fun logging(logging: Boolean) = apply { this.logging = logging }
84
+ fun disableSerializeRule(enabled: Boolean) = apply { this.disableSerializeRule = enabled }
82
85
 
83
86
  fun sslPinKeys(sslPinKey: String) = apply {
84
87
  this.sslPinKeys = Collections.singletonList(sslPinKey)
@@ -100,6 +103,7 @@ class RNNetmeraConfiguration private constructor(
100
103
  apiKey,
101
104
  firebaseSenderId,
102
105
  logging,
106
+ disableSerializeRule,
103
107
  sslPinKeys
104
108
  )
105
109
  }
@@ -3,6 +3,7 @@ package com.netmera.reactnativesdk
3
3
  import android.app.Activity
4
4
  import android.os.Bundle
5
5
  import android.util.Log
6
+ import com.facebook.react.bridge.Arguments
6
7
  import com.facebook.react.bridge.Promise
7
8
  import com.facebook.react.bridge.ReactApplicationContext
8
9
  import com.facebook.react.bridge.ReactContextBaseJavaModule
@@ -10,6 +11,8 @@ import com.facebook.react.bridge.ReactMethod
10
11
  import com.facebook.react.bridge.ReadableMap
11
12
  import com.facebook.react.modules.core.DeviceEventManagerModule
12
13
  import com.google.firebase.messaging.RemoteMessage
14
+ import com.google.gson.Gson
15
+ import com.google.gson.JsonObject
13
16
  import com.netmera.InternalNetmera
14
17
  import com.netmera.NMUser
15
18
  import com.netmera.Netmera
@@ -27,7 +30,10 @@ import com.netmera.callbacks.NMUpdateUserProfileListener
27
30
  import com.netmera.data.NMCategoryPreference
28
31
  import com.netmera.data.NMInboxStatusCount
29
32
  import com.netmera.data.NMInboxStatusCountFilter
33
+ import com.netmera.NetmeraCategoryFilter
34
+ import com.netmera.data.NMCouponDetail
30
35
  import com.netmera.reactnativesdk.RNNetmeraUtil.getInboxStatus
36
+ import com.netmera.reactnativesdk.RNNetmeraUtil.mapPushObject
31
37
  import com.netmera.reactnativesdk.RNNetmeraUtil.mapPushObjects
32
38
  import com.netmera.reactnativesdk.RNNetmeraUtil.parseInboxCountForStatusToMap
33
39
  import com.netmera.reactnativesdk.RNNetmeraUtil.toMap
@@ -136,7 +142,7 @@ class RNNetmeraModule(reactContext: ReactApplicationContext) :
136
142
  @ReactMethod
137
143
  fun fetchCoupons(page: Int, max: Int, promise: Promise) {
138
144
  Netmera.fetchCoupons(page, max, object : NMFetchCouponsResultListener {
139
- override fun onSuccess(coupons: List<com.netmera.data.NMCouponDetail>?) {
145
+ override fun onSuccess(coupons: List<NMCouponDetail>?) {
140
146
  promise.resolve(RNNetmeraUtil.mapCouponObjects(coupons ?: emptyList()))
141
147
  }
142
148
 
@@ -226,9 +232,23 @@ class RNNetmeraModule(reactContext: ReactApplicationContext) :
226
232
 
227
233
  @ReactMethod
228
234
  fun fetchCategory(readableMap: ReadableMap, promise: Promise) {
229
- Netmera.fetchCategory(
230
- RNNetmeraCategoryObject.getInboxObject(readableMap)
231
- ) { netmeraInboxCategory, netmeraError ->
235
+ val builder = NetmeraCategoryFilter.Builder()
236
+ if (readableMap.hasKey("status")) {
237
+ val status = readableMap.getInt("status")
238
+ builder.status(status)
239
+ }
240
+
241
+ if (readableMap.hasKey("pageSize")) {
242
+ val pageSize = readableMap.getInt("pageSize")
243
+ builder.pageSize(pageSize)
244
+ }
245
+
246
+ if (readableMap.hasKey("includeExpiredObjects")) {
247
+ val includeExpiredObjects = readableMap.getBoolean("includeExpiredObjects")
248
+ builder.includeExpiredObjects(includeExpiredObjects)
249
+ }
250
+
251
+ Netmera.fetchCategory(builder.build()) { netmeraInboxCategory, netmeraError ->
232
252
  setCategory(
233
253
  netmeraInboxCategory,
234
254
  netmeraError,
@@ -257,26 +277,6 @@ class RNNetmeraModule(reactContext: ReactApplicationContext) :
257
277
  }
258
278
  }
259
279
 
260
- @ReactMethod
261
- fun handleLastMessage(categoryName: String?, promise: Promise) {
262
- if (netmeraInboxCategory == null) {
263
- promise.reject(ERROR_CODE_NULL_CATEGORY, ERROR_MESSAGE_NULL_CATEGORY)
264
- return
265
- }
266
-
267
- if (categoryName == null || categoryName.isEmpty()) {
268
- promise.reject(ERROR_CODE_INVALID_PUSH_OBJECT, ERROR_MESSAGE_INVALID_PUSH_OBJECT)
269
- return
270
- }
271
-
272
- for (category in netmeraInboxCategory!!.categories()) {
273
- if (categoryName == category.categoryName) {
274
- Netmera.handlePushObject(reactApplicationContext.currentActivity!!, category.lastMessage)
275
- break
276
- }
277
- }
278
- }
279
-
280
280
  @ReactMethod
281
281
  fun updateStatusByCategories(fromIndex: Int, toIndex: Int, status: Int, promise: Promise) {
282
282
  if (netmeraInboxCategory == null) {
@@ -403,12 +403,12 @@ class RNNetmeraModule(reactContext: ReactApplicationContext) :
403
403
  @ReactMethod
404
404
  fun sendEvent(readableMap: ReadableMap?) {
405
405
  val eventMap = toMap(readableMap).toMutableMap()
406
- val event = RNNetmeraEvent()
406
+ val code = eventMap[CODE] as? String ?: return
407
+ if (code.isEmpty()) return
407
408
 
408
- if (eventMap.containsKey(CODE)) {
409
- event.setCode(readableMap?.getString(CODE)!!)
410
- eventMap.remove(CODE)
411
- }
409
+ val event = RNNetmeraEvent()
410
+ event.setCode(code)
411
+ eventMap.remove(CODE)
412
412
 
413
413
  if (eventMap.containsKey(REVENUE)) {
414
414
  event.setRevenue(readableMap?.getDouble(REVENUE) ?: 0.0)
@@ -615,7 +615,19 @@ class RNNetmeraModule(reactContext: ReactApplicationContext) :
615
615
  return
616
616
  }
617
617
  netmeraInboxCategory = nmInboxCategory
618
- promise.resolve(RNNetmeraCategoryObject.mapCategoryObjects(netmeraInboxCategory!!.categories()))
618
+
619
+ val writableArray = Arguments.createArray()
620
+ netmeraInboxCategory!!.categories().forEach { category ->
621
+ val map = Arguments.createMap()
622
+ map.putString("categoryName", category.categoryName)
623
+ map.putString("categoryStatus", Gson().toJson(category.status, JsonObject::class.java))
624
+ map.putInt("readCount", category.readCount)
625
+ map.putInt("unreadCount", category.unReadCount)
626
+ map.putInt("deletedCount", category.deletedCount)
627
+ map.putMap("lastMessage", mapPushObject(category.lastMessage))
628
+ writableArray.pushMap(map)
629
+ }
630
+ promise.resolve(writableArray)
619
631
  }
620
632
 
621
633
  companion object {
@@ -15,7 +15,7 @@ import com.netmera.callbacks.NMPushActionCallbacks
15
15
  import com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.Companion.TASK_KEY
16
16
  import com.netmera.reactnativesdk.RNNetmeraPushHeadlessService.Companion.TASK_MESSAGE
17
17
 
18
- class RNNetmeraPushBroadcastReceiver : NMPushActionCallbacks {
18
+ class RNNetmeraPushActionCallbacks : NMPushActionCallbacks {
19
19
 
20
20
  override fun onPushRegister(context: Context, gcmSenderId: String, pushToken: String) {
21
21
  val bundle = Bundle().apply {
package/ios/RNNetmera.h CHANGED
@@ -4,6 +4,9 @@
4
4
  */
5
5
 
6
6
  #import <Foundation/Foundation.h>
7
+ #import <React/RCTEventEmitter.h>
8
+ #import <React/RCTBridgeModule.h>
9
+ #import <React/RCTViewManager.h>
7
10
 
8
11
  //! Project version number for RNNetmera.
9
12
  FOUNDATION_EXPORT double RNNetmeraVersionNumber;
package/ios/RNNetmera.mm CHANGED
@@ -81,7 +81,7 @@ RCT_EXTERN_METHOD(inboxUpdateStatus:(NSInteger)fromIndex
81
81
  withResolver:(RCTPromiseResolveBlock)resolve
82
82
  withRejecter:(RCTPromiseRejectBlock)reject)
83
83
 
84
- RCT_EXTERN_METHOD(fetchCategory:(NSDictionary *)inboxDictionary
84
+ RCT_EXTERN_METHOD(fetchCategory:(NSDictionary *)filterDict
85
85
  withResolver:(RCTPromiseResolveBlock)resolve
86
86
  withRejecter:(RCTPromiseRejectBlock)reject)
87
87
 
@@ -97,10 +97,6 @@ RCT_EXTERN_METHOD(handleInteractiveAction:(NSString *)actionId
97
97
  withResolver:(RCTPromiseResolveBlock)resolve
98
98
  withRejecter:(RCTPromiseRejectBlock)reject)
99
99
 
100
- RCT_EXTERN_METHOD(handleLastMessage:(NSString *)pushId
101
- withResolver:(RCTPromiseResolveBlock)resolve
102
- withRejecter:(RCTPromiseRejectBlock)reject)
103
-
104
100
  RCT_EXTERN_METHOD(updateStatusByCategories:(NSArray<NSString *> *)categoryList
105
101
  status:(NSInteger)status
106
102
  withResolver:(RCTPromiseResolveBlock)resolve