react-native-moengage 7.3.0 → 7.4.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.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # react-native-moengage
2
2
  ---
3
3
  ## Change Log:
4
-
4
+ ### 7.4.0
5
+ Release Date: 12th May 2022
6
+ - Bugfix iOS: Fixed the PushClick callback issue in terminated state, that was appearing when the react-native version is above 0.65.
7
+
5
8
  ### 7.3.0
6
9
  Release Date: 16th September 2021
7
10
  - HTML InApp Support Added.
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
15
15
  s.platform = :ios, "10.0"
16
16
  s.source_files = 'iOS/MoEReactBridge/**/*.{h,m}'
17
17
  s.dependency 'React'
18
- s.dependency 'MoEPluginBase','>= 2.1.0','< 2.2.0'
18
+ s.dependency 'MoEPluginBase','>= 2.3.0','< 2.4.0'
19
19
 
20
20
  s.prepare_command = <<-CMD
21
21
  echo // Generated file, do not edit > iOS/MoEReactBridge/MOReactPluginInfo.h
@@ -10,6 +10,7 @@
10
10
  #import <MoEngage/MoEngage.h>
11
11
  #import <MoEPluginBase/MoEPluginBase.h>
12
12
  #import "MoEReactConstants.h"
13
+ #import "MoEReactBridge.h"
13
14
 
14
15
  @interface MOReactInitializer() <MoEPluginBridgeDelegate>
15
16
 
@@ -43,7 +44,6 @@
43
44
  }
44
45
 
45
46
  - (void)intializeSDKWithConfig:(MOSDKConfig*)sdkConfig withSDKState:(BOOL)isSdkEnabled andLaunchOptions:(NSDictionary*)launchOptions{
46
- [[MoEPluginBridge sharedInstance] trackPluginVersion:MO_REACT_PLUGIN_VERSION forIntegrationType:ReactNative];
47
47
  [MoEPluginBridge sharedInstance].bridgeDelegate = self;
48
48
 
49
49
  if (sdkConfig.moeAppID == nil || sdkConfig == nil) {
@@ -53,7 +53,7 @@
53
53
  sdkConfig.pluginIntegrationType = REACT_NATIVE;
54
54
  sdkConfig.pluginIntegrationVersion = MO_REACT_PLUGIN_VERSION;
55
55
 
56
- [[MoEPluginInitializer sharedInstance] intializeSDKWithConfig:sdkConfig withSDKState:isSdkEnabled andLaunchOptions:launchOptions];
56
+ [[MoEPluginInitializer sharedInstance] initializeSDKWithConfig:sdkConfig withSDKState:isSdkEnabled andLaunchOptions:launchOptions];
57
57
  }
58
58
 
59
59
  -(MOSDKConfig*)fetchSDKConfig {
@@ -164,9 +164,8 @@
164
164
  }
165
165
 
166
166
  NSDictionary* userInfo = @{kEventName:name,kPayloadDict:updatedDict};
167
- [[NSNotificationCenter defaultCenter] postNotificationName:kEventEmitted
168
- object:self
169
- userInfo:userInfo];
167
+ MoEReactBridge *reactBridge = [MoEReactBridge allocWithZone: nil];
168
+ [reactBridge sendEventWithName:userInfo];
170
169
 
171
170
  }
172
171
 
@@ -11,5 +11,5 @@
11
11
  #import <React/RCTEventEmitter.h>
12
12
 
13
13
  @interface MoEReactBridge : RCTEventEmitter <RCTBridgeModule>
14
-
14
+ -(void)sendEventWithName:(NSDictionary *)payloadDict;
15
15
  @end
@@ -16,38 +16,78 @@
16
16
  #import "MoEReactConstants.h"
17
17
 
18
18
  @interface MoEReactBridge()
19
-
20
19
  @end
21
20
 
22
21
  @implementation MoEReactBridge
23
22
 
23
+ {
24
+ bool hasListeners;
25
+ NSMutableArray *delayedEvents;
26
+ }
27
+
28
+ - (instancetype)init
29
+ {
30
+ if (self = [super init]) {
31
+ if (delayedEvents == nil)
32
+ delayedEvents = [NSMutableArray array];
33
+ }
34
+ return self;
35
+ }
36
+
37
+ + (id)allocWithZone:(NSZone *)zone {
38
+ static MoEReactBridge *sharedInstance = nil;
39
+ static dispatch_once_t onceToken;
40
+ dispatch_once(&onceToken, ^{
41
+ sharedInstance = [super allocWithZone:zone];
42
+ });
43
+ return sharedInstance;
44
+ }
45
+
46
+ + (BOOL)requiresMainQueueSetup {
47
+ return true;
48
+ }
49
+
24
50
  #pragma mark- Observers
25
51
  // Will be called when this module's first listener is added.
26
52
  -(void)startObserving {
27
- [[NSNotificationCenter defaultCenter] addObserver:self
28
- selector:@selector(emitEventInternal:)
29
- name:kEventEmitted
30
- object:nil];
53
+ hasListeners = YES;
54
+ [self flushDelayedEvents];
55
+
31
56
  }
32
57
 
33
58
  // Will be called when this module's last listener is removed, or on dealloc.
34
59
  -(void)stopObserving {
35
- [[NSNotificationCenter defaultCenter] removeObserver:self name:kEventEmitted object:nil];
60
+ hasListeners = NO;
36
61
  }
37
62
 
38
- -(void)emitEventInternal:(NSNotification *)notification
39
- {
40
- NSDictionary* userInfo = notification.userInfo;
41
- if (userInfo) {
42
- NSString* name = userInfo[kEventName];
43
- NSDictionary* payload = userInfo[kPayloadDict];
63
+ -(void)flushDelayedEvents{
64
+ if (delayedEvents.count > 0){
65
+ for (NSDictionary* payloadDict in delayedEvents){
66
+ [self emitEvent:payloadDict];
67
+ }
68
+ }
69
+
70
+ [delayedEvents removeAllObjects];
71
+ }
72
+
73
+ -(void)sendEventWithName:(NSDictionary *)payloadDict{
74
+ if (hasListeners) {
75
+ [self emitEvent:payloadDict];
76
+ } else {
77
+ [delayedEvents addObject:payloadDict];
78
+ }
79
+ }
80
+
81
+ -(void)emitEvent:(NSDictionary*)payloadDict{
82
+ if (payloadDict){
83
+ NSString* name = payloadDict[kEventName];
84
+ NSDictionary* payload = payloadDict[kPayloadDict];
44
85
  if (name != nil && payload != nil) {
45
86
  [self sendEventWithName:name body:payload];
46
87
  }
47
88
  }
48
89
  }
49
90
 
50
-
51
91
  #pragma mark- Event Emitters
52
92
  - (NSArray<NSString *> *)supportedEvents
53
93
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-moengage",
3
- "version": "7.3.0",
3
+ "version": "7.4.0",
4
4
  "description": "MoEngage is a mobile marketing automation company. This react-native SDK helps you track events, trigger smart notifications and in-apps, provides a drop-in Inbox Controller for notifications.",
5
5
  "main": "src/index.ts",
6
6
  "keywords": [