react-native-moengage-cards 3.1.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,9 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source = {:file => './' }
19
19
  s.source_files = "ios/**/*.{h,m,mm,swift}"
20
20
  s.dependency 'React'
21
-
22
- s.dependency 'MoEngagePluginCards','>= 1.7.0','< 1.8.0'
23
-
21
+ s.dependency 'MoEngagePluginCards','2.1.0'
24
22
 
25
23
  if defined?(install_modules_dependencies()) != nil
26
24
  install_modules_dependencies(s);
@@ -16,9 +16,9 @@ buildscript {
16
16
 
17
17
  ext {
18
18
  //dependency version
19
- moengageCoreVersion = "13.04.00"
20
- moengageCardsCoreVersion = "2.2.0"
21
- pluginBaseCardVersion = "2.1.0"
19
+ moengageCoreVersion = "13.05.00"
20
+ moengageCardsCoreVersion = "2.3.0"
21
+ pluginBaseCardVersion = "3.0.0"
22
22
  }
23
23
 
24
24
  apply plugin: 'com.android.library'
@@ -9,4 +9,4 @@ internal const val ARGUMENT_DATA: String = "data"
9
9
  internal const val ARGUMENT_CARDS: String = "cards"
10
10
  internal const val EVENT_METHOD_INBOX_OPEN_CARDS_SYNC = "onInboxOpenCardsSync"
11
11
  internal const val EVENT_PULL_TO_REFRESH_CARDS_SYNC = "onPullToRefreshCardsSync"
12
- internal const val EVENT_APP_OPEN_CARDS_SYNC = "onAppOpenCardsSync"
12
+ internal const val EVENT_GENERIC_CARDS_SYNC = "onCardsSync"
@@ -56,7 +56,7 @@ class EventEmitterImpl(private val reactContext: ReactContext) : CardsEventEmitt
56
56
  }
57
57
 
58
58
  val eventMapping = mapOf(
59
- CardEventType.APP_OPEN_SYNC to EVENT_APP_OPEN_CARDS_SYNC,
59
+ CardEventType.GENERIC_SYNC to EVENT_GENERIC_CARDS_SYNC,
60
60
  CardEventType.INBOX_OPEN_SYNC to EVENT_METHOD_INBOX_OPEN_CARDS_SYNC,
61
61
  CardEventType.PULL_TO_REFRESH_SYNC to EVENT_PULL_TO_REFRESH_CARDS_SYNC,
62
62
  )
@@ -31,7 +31,7 @@
31
31
  -(void)initialize:(NSString*)payload {
32
32
  NSDictionary* jsonPayload = [MoEngageReactUtils getJSONRepresentation:payload];
33
33
  [[MoEngagePluginCardsBridge sharedInstance] initialize:jsonPayload];
34
- [[MoEngagePluginCardsBridge sharedInstance] setAppOpenSyncListener:jsonPayload];
34
+ [[MoEngagePluginCardsBridge sharedInstance] setSyncListener:jsonPayload];
35
35
  [[MoEngagePluginCardsBridge sharedInstance] setSyncEventListnerDelegate:self];
36
36
  }
37
37
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  - (NSArray<NSString *> *)supportedEvents
24
24
  {
25
- return @[kAppOpenCardsSyncListener, kPullToRefreshCardsSyncListener, kInboxOpenCardsSyncListener];
25
+ return @[kCardsSyncListener, kPullToRefreshCardsSyncListener, kInboxOpenCardsSyncListener];
26
26
  }
27
27
 
28
28
  RCT_EXPORT_MODULE();
@@ -9,6 +9,6 @@
9
9
 
10
10
 
11
11
  extern NSString* const kPayload;
12
- extern NSString* const kAppOpenCardsSyncListener;
12
+ extern NSString* const kCardsSyncListener;
13
13
  extern NSString* const kPullToRefreshCardsSyncListener;
14
14
  extern NSString* const kInboxOpenCardsSyncListener;
@@ -9,7 +9,7 @@
9
9
  #import "MoEngageCardsReactConstants.h"
10
10
 
11
11
  NSString* const kPayload = @"payload";
12
- NSString* const kAppOpenCardsSyncListener = @"onAppOpenCardsSync";
12
+ NSString* const kCardsSyncListener = @"onCardsSync";
13
13
  NSString* const kPullToRefreshCardsSyncListener = @"onPullToRefreshCardsSync";
14
14
  NSString* const kInboxOpenCardsSyncListener = @"onInboxOpenCardsSync";
15
15
 
@@ -17,7 +17,8 @@
17
17
  return kPullToRefreshCardsSyncListener;
18
18
 
19
19
  case MoEngageCardsSyncEventTypeAppOpen:
20
- return kAppOpenCardsSyncListener;
20
+ case MoEngageCardsSyncEventTypeImmediate:
21
+ return kCardsSyncListener;
21
22
 
22
23
  case MoEngageCardsSyncEventTypeInboxOpen:
23
24
  return kInboxOpenCardsSyncListener;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage-cards",
3
- "version": "3.1.0",
3
+ "version": "5.0.0",
4
4
  "description": "Cards Module for the MoEngage Platform",
5
5
  "main": "src/index.ts",
6
6
  "keywords": [
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "license": "SEE LICENSE IN LICENSE.txt",
32
32
  "peerDependencies": {
33
- "react-native-moengage": "^10.0.1"
33
+ "react-native-moengage": "^11.0.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/jest": "^29.5.0",
@@ -6,7 +6,7 @@ import CardInfo from "./model/CardInfo";
6
6
  import CardsData from "./model/CardsData";
7
7
  import SyncCompleteData from "./model/SyncData";
8
8
  import { MoEngageLogger } from "react-native-moengage";
9
- import SyncType from "./model/enums/SyncType";
9
+ import CardListenerEvent from "./model/enums/CardListenerEvent";
10
10
 
11
11
  /**
12
12
  * Helper to interact with the cards feature.
@@ -33,15 +33,15 @@ namespace ReactMoEngageCards {
33
33
  }
34
34
 
35
35
  /**
36
- * Set a listener to receive callback for cards refresh on App open
36
+ * Set a listener to receive callback for cards refresh on App open , or on user logs in
37
37
  * Notes: This method must be call before initialize to get callback properly
38
38
  *
39
39
  * @param onSyncComplete - Callback to be trigger on sync complete
40
- * @since 1.0.0
40
+ * @since 4.0.0
41
41
  */
42
- export function setAppOpenSyncListener(onSyncComplete: (data: SyncCompleteData | null) => void): void {
43
- MoEngageLogger.verbose(`${TAG} setAppOpenSyncListener() : `);
44
- MoEngageCardsCache.cacheEventListenerCallback(SyncType.APP_OPEN, onSyncComplete);
42
+ export function setSyncCompleteListener(onSyncComplete: (data: SyncCompleteData | null) => void): void {
43
+ MoEngageLogger.verbose(`${TAG} setSyncCompleteListener() : `);
44
+ MoEngageCardsCache.cacheEventListenerCallback(CardListenerEvent.GENERIC, onSyncComplete);
45
45
  }
46
46
 
47
47
  /**
@@ -83,4 +83,4 @@ export const keyUnClickedCardsCount = "unClickedCardsCount";
83
83
  //JSON Values export constants
84
84
  export const argumentPullToRefreshSync = "onPullToRefreshCardsSync";
85
85
  export const argumentInboxOpenSync = "onInboxOpenCardsSync";
86
- export const argumentAppOpenSync = "onAppOpenCardsSync";
86
+ export const argumentGenericSync = "onCardsSync";
@@ -1,7 +1,6 @@
1
1
  import { NativeEventEmitter } from "react-native";
2
2
  import SyncCompleteData from "../model/SyncData";
3
3
  import MoEngageCardsCache from "./MoEngageCardsCache";
4
- import SyncType from "../model/enums/SyncType";
5
4
  import {
6
5
  getAllCategoryStatusFromPayload,
7
6
  getCardInfoFromPayload,
@@ -19,9 +18,9 @@ import {
19
18
  keyData,
20
19
  keyPayload,
21
20
  keySyncCompleteData,
22
- argumentAppOpenSync,
23
21
  argumentInboxOpenSync,
24
- argumentPullToRefreshSync
22
+ argumentPullToRefreshSync,
23
+ argumentGenericSync
25
24
  } from "./Constants";
26
25
  import { MoEngageLogger } from "react-native-moengage";
27
26
  import { syncDataFromJson } from "./utils/JsonToModelMapper";
@@ -33,6 +32,7 @@ import {
33
32
  getCardsForCategoriesPayload,
34
33
  getDeleteCardsPayload
35
34
  } from "./utils/PayloadBuilder";
35
+ import CardListenerEvent from "../model/enums/CardListenerEvent";
36
36
 
37
37
  let MoEngageEventEmitter: { addListener: (arg0: any, arg1: (data: any) => void) => void; };
38
38
 
@@ -68,7 +68,7 @@ class MoEngageCardHandler {
68
68
 
69
69
  refreshCards(onSyncComplete: (data: SyncCompleteData | null) => void): void {
70
70
  try {
71
- MoEngageCardsCache.cacheEventListenerCallback(SyncType.PULL_TO_REFRESH, onSyncComplete);
71
+ MoEngageCardsCache.cacheEventListenerCallback(CardListenerEvent.PULL_TO_REFRESH, onSyncComplete);
72
72
  MoEngageCardsBridge.refreshCards(getAccountMetaPayload(this.appId));
73
73
  MoEngageLogger.verbose(`${this.TAG} Executed - refreshCards() `);
74
74
  } catch (error) {
@@ -78,7 +78,7 @@ class MoEngageCardHandler {
78
78
 
79
79
  onCardSectionLoaded(onSyncComplete: (data: SyncCompleteData | null) => void): void {
80
80
  try {
81
- MoEngageCardsCache.cacheEventListenerCallback(SyncType.INBOX_OPEN, onSyncComplete);
81
+ MoEngageCardsCache.cacheEventListenerCallback(CardListenerEvent.INBOX_OPEN, onSyncComplete);
82
82
  MoEngageCardsBridge.onCardSectionLoaded(getAccountMetaPayload(this.appId));
83
83
  MoEngageLogger.verbose(`${this.TAG} Executed - onCardSectionLoaded() `);
84
84
  } catch (error) {
@@ -88,7 +88,7 @@ class MoEngageCardHandler {
88
88
 
89
89
  onCardSectionUnLoaded(): void {
90
90
  try {
91
- MoEngageCardsCache.removeCacheForEvent(SyncType.INBOX_OPEN);
91
+ MoEngageCardsCache.removeCacheForEvent(CardListenerEvent.INBOX_OPEN);
92
92
  MoEngageCardsBridge.onCardSectionUnLoaded(getAccountMetaPayload(this.appId));
93
93
  MoEngageLogger.verbose(`${this.TAG} Executed - onCardSectionUnLoaded() `);
94
94
  } catch (error) {
@@ -232,22 +232,22 @@ class MoEngageCardHandler {
232
232
 
233
233
  private addBridgeEventListener(): void {
234
234
  MoEngageEventEmitter.addListener(
235
- argumentAppOpenSync,
236
- (data) => this.handleCallbackForSyncEvent(SyncType.APP_OPEN, data)
235
+ argumentGenericSync,
236
+ (data) => this.handleCallbackForSyncEvent(CardListenerEvent.GENERIC, data)
237
237
  );
238
238
 
239
239
  MoEngageEventEmitter.addListener(
240
240
  argumentPullToRefreshSync,
241
- (data) => this.handleCallbackForSyncEvent(SyncType.PULL_TO_REFRESH, data)
241
+ (data) => this.handleCallbackForSyncEvent(CardListenerEvent.PULL_TO_REFRESH, data)
242
242
  );
243
243
 
244
244
  MoEngageEventEmitter.addListener(
245
245
  argumentInboxOpenSync,
246
- (data) => this.handleCallbackForSyncEvent(SyncType.INBOX_OPEN, data)
246
+ (data) => this.handleCallbackForSyncEvent(CardListenerEvent.INBOX_OPEN, data)
247
247
  );
248
248
  }
249
249
 
250
- private handleCallbackForSyncEvent(syncType: SyncType, data: { [k: string]: any }): void {
250
+ private handleCallbackForSyncEvent(syncType: CardListenerEvent, data: { [k: string]: any }): void {
251
251
  try {
252
252
  const payload = data[keyPayload];
253
253
  const dataJson = JSON.parse(payload)[keyData];
@@ -1,5 +1,5 @@
1
1
  import SyncCompleteData from "../model/SyncData";
2
- import SyncType from "../model/enums/SyncType";
2
+ import CardListenerEvent from "../model/enums/CardListenerEvent";
3
3
 
4
4
  /**
5
5
  * Global Cache to store the cache for Cards Plugin
@@ -13,17 +13,17 @@ namespace MoEngageCardsCache {
13
13
  * Sync Event Listener Cache
14
14
  * @since 1.0.0
15
15
  */
16
- let eventListenerCache: Map<SyncType, (data: SyncCompleteData | null) => void> = new Map();
16
+ let eventListenerCache: Map<CardListenerEvent, (data: SyncCompleteData | null) => void> = new Map();
17
17
 
18
- export function cacheEventListenerCallback(syncType: SyncType, onTrigger: (data: SyncCompleteData | null) => void): void {
18
+ export function cacheEventListenerCallback(syncType: CardListenerEvent, onTrigger: (data: SyncCompleteData | null) => void): void {
19
19
  eventListenerCache.set(syncType, onTrigger);
20
20
  }
21
21
 
22
- export function getCallbackForCachedEvent(syncType: SyncType): ((data: SyncCompleteData | null) => void) | undefined {
22
+ export function getCallbackForCachedEvent(syncType: CardListenerEvent): ((data: SyncCompleteData | null) => void) | undefined {
23
23
  return eventListenerCache.get(syncType);
24
24
  }
25
25
 
26
- export function removeCacheForEvent(syncType: SyncType): void {
26
+ export function removeCacheForEvent(syncType: CardListenerEvent): void {
27
27
  eventListenerCache.delete(syncType);
28
28
  }
29
29
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Card Emitter Event type
3
+ *
4
+ * @author Rakshitha
5
+ * @since 4.0.0
6
+ */
7
+
8
+ enum CardListenerEvent {
9
+ /**
10
+ * Sync when application comes to foreground/anonymous user logins
11
+ * @since 4.0.0
12
+ */
13
+ GENERIC = "GENERIC",
14
+
15
+ /**
16
+ * Sync when inbox screen opened.
17
+ * @since 4.0.0
18
+ */
19
+ INBOX_OPEN = "INBOX_OPEN",
20
+
21
+ /**
22
+ * Sync when SwipeToRefresh widget is pulled.
23
+ * @since 4.0.0
24
+ */
25
+ PULL_TO_REFRESH = "PULL_TO_REFRESH",
26
+ }
27
+
28
+ export default CardListenerEvent;
@@ -22,7 +22,13 @@ enum SyncType {
22
22
  * Sync when SwipeToRefresh widget is pulled.
23
23
  * @since 1.0.0
24
24
  */
25
- PULL_TO_REFRESH = "PULL_TO_REFRESH"
25
+ PULL_TO_REFRESH = "PULL_TO_REFRESH",
26
+
27
+ /**
28
+ * Sync when User logins .
29
+ * @since 4.0.0
30
+ */
31
+ IMMEDIATE = "IMMEDIATE"
26
32
  }
27
33
 
28
34
  export default SyncType;