infobip-mobile-messaging-react-native-plugin 6.1.0 → 6.2.2
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 +91 -79
- package/android/build.gradle +1 -1
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/CacheManager.java +6 -2
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMChatModule.java +4 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeEvent.java +12 -5
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeMobileMessagingModule.java +1 -1
- package/index.d.ts +7 -0
- package/index.js +9 -0
- package/infobip-mobile-messaging-react-native-plugin-6.2.1.tgz +0 -0
- package/infobip-mobile-messaging-react-native-plugin.podspec +4 -4
- package/ios/Cartfile +1 -1
- package/ios/Cartfile.resolved +1 -1
- package/ios/MobileMessagingPlugin/RNMMChat.swift +5 -0
- package/ios/MobileMessagingPlugin/RNMMChatBridge.m +1 -0
- package/ios/MobileMessagingPlugin/RNMobileMessaging.swift +21 -6
- package/ios/MobileMessagingPlugin/RNMobileMessagingEventsManager.swift +1 -1
- package/ios/ReactNativeMobileMessaging-Bridging-Header.h +1 -0
- package/package.json +1 -1
- package/infobip-mobile-messaging-react-native-plugin-6.0.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/infobip-mobile-messaging-react-native-plugin)
|
|
4
4
|
|
|
5
|
-
Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in your application and access to the features of [Infobip IP Messaging Platform](https://portal.infobip.com/push/).
|
|
5
|
+
Mobile Messaging SDK is designed and developed to easily enable push notification channel in your mobile application. In almost no time of implementation you get push notification in your application and access to the features of [Infobip IP Messaging Platform](https://portal.infobip.com/push/).
|
|
6
6
|
The document describes library integration steps for your React Native project.
|
|
7
7
|
|
|
8
8
|
* [Requirements](#requirements)
|
|
@@ -17,12 +17,12 @@ The document describes library integration steps for your React Native project.
|
|
|
17
17
|
For iOS project:
|
|
18
18
|
- Xcode and Command Line Tools (13.2.1)
|
|
19
19
|
- CocoaPods (v1.11.3)
|
|
20
|
-
- Minimum deployment target
|
|
20
|
+
- Minimum deployment target 12.0
|
|
21
21
|
|
|
22
22
|
For Android project:
|
|
23
23
|
- Android Studio (Bumblebee | 2021.1.1)
|
|
24
24
|
- Gradle (v7.3.3)
|
|
25
|
-
-
|
|
25
|
+
- Supported API Levels: 21 (Android 5.0 - [Lollipop](https://developer.android.com/about/versions/lollipop)) - 31 (Android 12.0)
|
|
26
26
|
|
|
27
27
|
## Quick start guide
|
|
28
28
|
|
|
@@ -38,51 +38,63 @@ This guide is designed to get you up and running with Mobile Messaging SDK plugi
|
|
|
38
38
|
|
|
39
39
|
3. Configure platforms
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>
|
|
48
|
-
|
|
49
|
-
@implementation AppDelegate
|
|
50
|
-
|
|
51
|
-
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
52
|
-
{
|
|
53
|
-
[MobileMessagingPluginApplicationDelegate install];
|
|
54
|
-
...
|
|
55
|
-
}
|
|
56
|
-
...
|
|
57
|
-
```
|
|
58
|
-
4. Configure your project to support Push Notification as described in item 2 of [iOS integration quick start guide](https://github.com/infobip/mobile-messaging-sdk-ios#quick-start-guide)
|
|
59
|
-
5. [Integrate Notification Service Extension](https://github.com/infobip/mobile-messaging-sdk-ios/wiki/Notification-Service-Extension-for-Rich-Notifications-and-better-delivery-reporting-on-iOS-10) into your app in order to obtain:
|
|
60
|
-
- more accurate processing of messages and delivery stats
|
|
61
|
-
- support of rich notifications on the lock screen
|
|
62
|
-
- **Android**
|
|
63
|
-
1. Following paths should be provided in .bash_profile
|
|
64
|
-
```sh
|
|
65
|
-
export ANDROID_HOME=$HOME/Library/Android/sdk
|
|
66
|
-
export PATH=$PATH:$ANDROID_HOME/emulator
|
|
67
|
-
export PATH=$PATH:$ANDROID_HOME/tools
|
|
68
|
-
export PATH=$PATH:$ANDROID_HOME/tools/bin
|
|
69
|
-
export PATH=$PATH:$ANDROID_HOME/platform-tools
|
|
70
|
-
```
|
|
71
|
-
2. Add 'com.google.gms:google-services' to `android/build.gradle` file
|
|
72
|
-
```groovy
|
|
73
|
-
buildscript {
|
|
41
|
+
- **iOS**
|
|
42
|
+
> ### Notice
|
|
43
|
+
> Starting from the [6.2.0](https://github.com/infobip/mobile-messaging-react-native-plugin/releases/tag/6.1.0) plugin version it's not mandatory to add `use_frameworks!` to the `Podfile`, check the [Migration guide](https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Migration-guides#migration-from-610-to-620-in-case-you-are-getting-rid-of-use_frameworks-in-the-podfile) if you want to get rid of it.
|
|
44
|
+
1. Run `pod install` from `/ios` folder (installs Mobile Messaging native SDK)
|
|
45
|
+
2. Import following header `#import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>` and add `[MobileMessagingPluginApplicationDelegate install];` into `/ios/<ProjectName>/AppDelegate.m` (this is required for OS callbacks such as `didRegisterForRemoteNotifications` to be intercepted by native MobileMessaging SDK)
|
|
46
|
+
```objective-c
|
|
74
47
|
...
|
|
75
|
-
|
|
48
|
+
#import <MobileMessaging/MobileMessagingPluginApplicationDelegate.h>
|
|
49
|
+
|
|
50
|
+
@implementation AppDelegate
|
|
51
|
+
|
|
52
|
+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
53
|
+
{
|
|
54
|
+
[MobileMessagingPluginApplicationDelegate install];
|
|
76
55
|
...
|
|
77
|
-
//GMS Gradle plugin
|
|
78
|
-
classpath 'com.google.gms:google-services:4.3.10'
|
|
79
56
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
57
|
+
...
|
|
58
|
+
```
|
|
59
|
+
3. Configure your project to support Push Notification as described in item 2 of [iOS integration quick start guide](https://github.com/infobip/mobile-messaging-sdk-ios#quick-start-guide)
|
|
60
|
+
4. [Integrate Notification Service Extension](https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Delivery-improvements-and-rich-content-notifications#setting-up-ios-part) into your app in order to obtain:
|
|
61
|
+
- more accurate processing of messages and delivery stats
|
|
62
|
+
- support of rich notifications on the lock screen
|
|
63
|
+
- **Android**
|
|
64
|
+
1. Following paths should be provided in .bash_profile
|
|
65
|
+
```sh
|
|
66
|
+
export ANDROID_HOME=$HOME/Library/Android/sdk
|
|
67
|
+
export PATH=$PATH:$ANDROID_HOME/emulator
|
|
68
|
+
export PATH=$PATH:$ANDROID_HOME/tools
|
|
69
|
+
export PATH=$PATH:$ANDROID_HOME/tools/bin
|
|
70
|
+
export PATH=$PATH:$ANDROID_HOME/platform-tools
|
|
71
|
+
```
|
|
72
|
+
2. Add 'com.google.gms:google-services' to `android/build.gradle` file
|
|
73
|
+
```groovy
|
|
74
|
+
buildscript {
|
|
75
|
+
...
|
|
76
|
+
dependencies {
|
|
77
|
+
...
|
|
78
|
+
//GMS Gradle plugin
|
|
79
|
+
classpath 'com.google.gms:google-services:4.3.10'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
And add `apply plugin: 'com.google.gms.google-services'` at the end of your `android/app/build.gradle` in order to apply [Google Services Gradle Plugin](https://developers.google.com/android/guides/google-services-plugin)
|
|
84
|
+
|
|
85
|
+
3. Add a Firebase configuration file (google-services.json) as described in <a href="https://firebase.google.com/docs/android/setup#add-config-file" target="_blank">`Firebase documentation`</a>. Check <a href="https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Applying-Firebase-configuration-in-MobileMessaging-SDK">Applying Firebase configuration in MobileMessaging SDK Guide</a> for alternatives.
|
|
86
|
+
|
|
87
|
+
> ### Notice (check if you don't plan to use [Geofencing](https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Geofencing#android)):
|
|
88
|
+
> As long as Geofencing is automatically included to the plugin, it adds required geo permissions automatically. You can remove them from `/android/app/src/main/AndroidManifest.xml` by adding following:
|
|
89
|
+
> ```
|
|
90
|
+
> <manifest ... xmlns:tools="http://schemas.android.com/tools">
|
|
91
|
+
> ...
|
|
92
|
+
> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" tools:node="remove" />
|
|
93
|
+
> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" tools:node="remove" />
|
|
94
|
+
> <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove" />
|
|
95
|
+
> ...
|
|
96
|
+
> </manifest>
|
|
97
|
+
> ```
|
|
86
98
|
|
|
87
99
|
## Initialization configuration
|
|
88
100
|
|
|
@@ -90,24 +102,24 @@ Initialize Mobile Messaging React Native plugin, provide application configurati
|
|
|
90
102
|
|
|
91
103
|
```javascript
|
|
92
104
|
import { mobileMessaging } from 'infobip-mobile-messaging-react-native-plugin';
|
|
93
|
-
|
|
105
|
+
|
|
94
106
|
someMethod(): void {
|
|
95
|
-
...
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
...
|
|
108
|
+
|
|
109
|
+
mobileMessaging.init(
|
|
110
|
+
{
|
|
111
|
+
applicationCode: '<your app code>',
|
|
112
|
+
ios: {
|
|
113
|
+
notificationTypes: ['alert', 'badge', 'sound'],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
() => {
|
|
117
|
+
console.log('MobileMessaging started');
|
|
118
|
+
},
|
|
119
|
+
error => {
|
|
120
|
+
console.log('MobileMessaging error: ', error);
|
|
121
|
+
},
|
|
122
|
+
);
|
|
111
123
|
}
|
|
112
124
|
```
|
|
113
125
|
<details><summary>expand to see TypeScript code</summary>
|
|
@@ -115,24 +127,24 @@ someMethod(): void {
|
|
|
115
127
|
|
|
116
128
|
```typescript
|
|
117
129
|
import { mobileMessaging } from 'infobip-mobile-messaging-react-native-plugin';
|
|
118
|
-
|
|
130
|
+
|
|
119
131
|
someMethod(): void {
|
|
120
|
-
...
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
mobileMessaging.init(
|
|
135
|
+
{
|
|
136
|
+
applicationCode: '<your app code>',
|
|
137
|
+
ios: {
|
|
138
|
+
notificationTypes: ['alert', 'badge', 'sound'],
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
() => {
|
|
142
|
+
console.log('MobileMessaging started');
|
|
143
|
+
},
|
|
144
|
+
(error: MobileMessagingError) => {
|
|
145
|
+
console.log('MobileMessaging error: ', error);
|
|
146
|
+
},
|
|
147
|
+
);
|
|
136
148
|
}
|
|
137
149
|
```
|
|
138
150
|
|
package/android/build.gradle
CHANGED
|
@@ -22,10 +22,12 @@ class CacheManager {
|
|
|
22
22
|
|
|
23
23
|
static class Event {
|
|
24
24
|
String type;
|
|
25
|
+
JSONObject jsonObject;
|
|
25
26
|
Object[] objects = null;
|
|
26
27
|
|
|
27
|
-
Event(String type, Object ... objects) {
|
|
28
|
+
Event(String type, JSONObject object, Object ... objects) {
|
|
28
29
|
this.type = type;
|
|
30
|
+
this.jsonObject = object;
|
|
29
31
|
this.objects = objects;
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -33,6 +35,7 @@ class CacheManager {
|
|
|
33
35
|
public String toString() {
|
|
34
36
|
return type;
|
|
35
37
|
}
|
|
38
|
+
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
static void saveEvent(Context context, String event, JSONObject object, String actionId, String actionInputText) {
|
|
@@ -41,7 +44,8 @@ class CacheManager {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
static void saveEvent(Context context, String event, int unreadMessagesCounter) {
|
|
44
|
-
|
|
47
|
+
//int `unreadMessagesCounter` isn't a JSONObject, so it'll go as a second argument
|
|
48
|
+
String serialized = serializer.serialize(new Event(event, null, unreadMessagesCounter));
|
|
45
49
|
saveStringsToSet(context, EVENTS_KEY, serialized);
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -50,6 +50,10 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
|
|
|
50
50
|
InAppChat.getInstance(reactContext).resetMessageCounter();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
@ReactMethod
|
|
54
|
+
public void setLanguage(String localeString){
|
|
55
|
+
InAppChat.getInstance(reactContext).setLanguage(localeString);
|
|
56
|
+
}
|
|
53
57
|
@Override
|
|
54
58
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
55
59
|
FragmentActivity fragmentActivity = Utils.getFragmentActivity(reactContext);
|
package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeEvent.java
CHANGED
|
@@ -2,16 +2,13 @@ package org.infobip.reactlibrary.mobilemessaging;
|
|
|
2
2
|
|
|
3
3
|
import android.util.Log;
|
|
4
4
|
|
|
5
|
-
import com.facebook.react.bridge.Callback;
|
|
6
5
|
import com.facebook.react.bridge.ReactContext;
|
|
7
6
|
import com.facebook.react.bridge.ReadableArray;
|
|
8
7
|
import com.facebook.react.bridge.ReadableMap;
|
|
9
8
|
import com.facebook.react.bridge.WritableArray;
|
|
10
|
-
import com.facebook.react.bridge.WritableMap;
|
|
11
9
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
12
|
-
import com.facebook.react.bridge.WritableNativeMap;
|
|
13
10
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
14
|
-
|
|
11
|
+
|
|
15
12
|
import org.infobip.reactlibrary.mobilemessaging.datamappers.ReactNativeJson;
|
|
16
13
|
|
|
17
14
|
import org.json.JSONArray;
|
|
@@ -20,8 +17,13 @@ import org.json.JSONObject;
|
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
class ReactNativeEvent {
|
|
20
|
+
|
|
23
21
|
static void send(String eventName, ReactContext reactContext, Object... objects) {
|
|
24
|
-
|
|
22
|
+
send(eventName, reactContext, null, objects);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static void send(String eventName, ReactContext reactContext, JSONObject jsonObject, Object... objects) {
|
|
26
|
+
if (jsonObject == null && objects == null) {
|
|
25
27
|
Log.d(Utils.TAG, "objects are null, so another method should be used");
|
|
26
28
|
send(eventName, reactContext);
|
|
27
29
|
return;
|
|
@@ -31,6 +33,11 @@ class ReactNativeEvent {
|
|
|
31
33
|
array.pushString(eventName);
|
|
32
34
|
|
|
33
35
|
try {
|
|
36
|
+
|
|
37
|
+
if (jsonObject != null) {
|
|
38
|
+
array.pushMap(ReactNativeJson.convertJsonToMap(jsonObject));
|
|
39
|
+
}
|
|
40
|
+
|
|
34
41
|
for (Object value : objects) {
|
|
35
42
|
if (value == null) {
|
|
36
43
|
continue;
|
|
@@ -70,7 +70,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
70
70
|
public void initialize() {
|
|
71
71
|
super.initialize();
|
|
72
72
|
for (CacheManager.Event event : CacheManager.loadEvents(reactContext)) {
|
|
73
|
-
ReactNativeEvent.send(event.type, reactContext, event.objects);
|
|
73
|
+
ReactNativeEvent.send(event.type, reactContext, event.jsonObject, event.objects);
|
|
74
74
|
}
|
|
75
75
|
pluginInitialized = true;
|
|
76
76
|
registerBroadcastReceiver();
|
package/index.d.ts
CHANGED
|
@@ -460,6 +460,13 @@ declare namespace MobileMessagingReactNative {
|
|
|
460
460
|
*/
|
|
461
461
|
setupiOSChatSettings(settings: ChatSettingsIOS): void;
|
|
462
462
|
|
|
463
|
+
/**
|
|
464
|
+
* Set chat language
|
|
465
|
+
*
|
|
466
|
+
* @param localeString
|
|
467
|
+
*/
|
|
468
|
+
setLanguage(localeString: string): void;
|
|
469
|
+
|
|
463
470
|
/**
|
|
464
471
|
* Returns unread in-app chat push messages counter.
|
|
465
472
|
* The counter increments each time the application receives in-app chat push message
|
package/index.js
CHANGED
|
@@ -546,6 +546,15 @@ class MobileMessaging {
|
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
548
|
|
|
549
|
+
/**
|
|
550
|
+
* The predefined messages prompted within the In-app chat (such as status updates, button titles, input field prompt) by default are
|
|
551
|
+
* localized using system locale setting, but can be easily changed providing your locale string with the following formats:
|
|
552
|
+
* "es_ES", "es-ES" or "es"
|
|
553
|
+
*/
|
|
554
|
+
setLanguage(localeString) {
|
|
555
|
+
RNMMChat.setLanguage(localeString);
|
|
556
|
+
};
|
|
557
|
+
|
|
549
558
|
/**
|
|
550
559
|
* Returns unread in-app chat push messages counter.
|
|
551
560
|
* The counter increments each time the application receives in-app chat push message
|
|
Binary file
|
|
@@ -12,15 +12,15 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
s.homepage = "https://github.com/infobip/mobile-messaging-react-native-plugin"
|
|
13
13
|
s.license = "MIT"
|
|
14
14
|
s.authors = { "Infobip" => "Push.Support@infobip.com" }
|
|
15
|
-
s.platforms = { :ios => "
|
|
15
|
+
s.platforms = { :ios => "12.0" }
|
|
16
16
|
s.source = { :git => 'https://github.com/infobip/mobile-messaging-react-native-plugin.git', :tag => s.version}
|
|
17
17
|
s.swift_version = '5'
|
|
18
18
|
s.source_files = "ios/**/*.{h,m,swift}"
|
|
19
19
|
s.requires_arc = true
|
|
20
20
|
|
|
21
21
|
s.dependency "React-Core"
|
|
22
|
-
s.dependency "MobileMessaging/Core", "
|
|
23
|
-
s.dependency "MobileMessaging/Geofencing", "
|
|
24
|
-
s.dependency "MobileMessaging/InAppChat", "
|
|
22
|
+
s.dependency "MobileMessaging/Core", "10.2.1"
|
|
23
|
+
s.dependency "MobileMessaging/Geofencing", "10.2.1"
|
|
24
|
+
s.dependency "MobileMessaging/InAppChat", "10.2.1"
|
|
25
25
|
|
|
26
26
|
end
|
package/ios/Cartfile
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "infobip/mobile-messaging-sdk-ios" "
|
|
1
|
+
github "infobip/mobile-messaging-sdk-ios" "10.2.1"
|
package/ios/Cartfile.resolved
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
github "infobip/mobile-messaging-sdk-ios" "
|
|
1
|
+
github "infobip/mobile-messaging-sdk-ios" "10.2.1"
|
|
@@ -20,6 +20,7 @@ RCT_EXTERN_METHOD(showChat:)
|
|
|
20
20
|
RCT_EXTERN_METHOD(getMessageCounter:(RCTResponseSenderBlock)resultCallback)
|
|
21
21
|
RCT_EXTERN_METHOD(resetMessageCounter)
|
|
22
22
|
RCT_EXTERN_METHOD(setupChatSettings:)
|
|
23
|
+
RCT_EXTERN_METHOD(setLanguage:)
|
|
23
24
|
|
|
24
25
|
- (dispatch_queue_t)methodQueue {
|
|
25
26
|
return dispatch_get_main_queue();
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
import MobileMessaging
|
|
10
10
|
|
|
11
|
+
// It may happen that RN call module initialization more than once,
|
|
12
|
+
// Not needed to perform early start more than once per application session.
|
|
13
|
+
var isEarlyStartPerformed = false;
|
|
14
|
+
|
|
11
15
|
@objc(ReactNativeMobileMessaging)
|
|
12
16
|
class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
13
17
|
private var messageStorageAdapter: MessageStorageAdapter?
|
|
@@ -47,6 +51,13 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
47
51
|
super.stopObserving()
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
override func sendEvent(withName name: String!, body: Any!) {
|
|
55
|
+
guard let _eventsManager = eventsManager, _eventsManager.hasEventListeners == true else {
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
super.sendEvent(withName: name, body: body)
|
|
59
|
+
}
|
|
60
|
+
|
|
50
61
|
@objc
|
|
51
62
|
override static func requiresMainQueueSetup() -> Bool {
|
|
52
63
|
return true
|
|
@@ -79,8 +90,9 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
79
90
|
let cachedConfigDict = RNMobileMessagingConfiguration.getRawConfigFromDefaults()
|
|
80
91
|
if let cachedConfigDict = cachedConfigDict, (config as NSDictionary) != (cachedConfigDict as NSDictionary)
|
|
81
92
|
{
|
|
82
|
-
stop
|
|
83
|
-
|
|
93
|
+
stop {
|
|
94
|
+
self.start(configuration: configuration, onSuccess: successCallback)
|
|
95
|
+
}
|
|
84
96
|
} else if cachedConfigDict == nil {
|
|
85
97
|
start(configuration: configuration, onSuccess: successCallback)
|
|
86
98
|
} else {
|
|
@@ -91,9 +103,12 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
91
103
|
private func performEarlyStartIfPossible() {
|
|
92
104
|
if let cachedConfigDict = RNMobileMessagingConfiguration.getRawConfigFromDefaults(),
|
|
93
105
|
let configuration = RNMobileMessagingConfiguration(rawConfig: cachedConfigDict),
|
|
94
|
-
!self.isStarted
|
|
106
|
+
!self.isStarted,
|
|
107
|
+
!isEarlyStartPerformed
|
|
95
108
|
{
|
|
96
|
-
|
|
109
|
+
MMLogDebug("[RNMobileMessaging] Performing early start")
|
|
110
|
+
isEarlyStartPerformed = true
|
|
111
|
+
start(configuration: configuration) { response in }
|
|
97
112
|
}
|
|
98
113
|
}
|
|
99
114
|
|
|
@@ -134,9 +149,9 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
134
149
|
})
|
|
135
150
|
}
|
|
136
151
|
|
|
137
|
-
private func stop() {
|
|
138
|
-
MobileMessaging.stop()
|
|
152
|
+
private func stop(completion: @escaping () -> Void) {
|
|
139
153
|
eventsManager?.stop()
|
|
154
|
+
MobileMessaging.stop(false, completion: completion)
|
|
140
155
|
}
|
|
141
156
|
|
|
142
157
|
/*User Profile Management*/
|
|
@@ -10,7 +10,7 @@ import MobileMessaging
|
|
|
10
10
|
|
|
11
11
|
class RNMobileMessagingEventsManager {
|
|
12
12
|
private var eventEmitter: RCTEventEmitter!
|
|
13
|
-
|
|
13
|
+
public var hasEventListeners = false
|
|
14
14
|
private var cachedMobileMessagingNotifications = [Notification]()
|
|
15
15
|
|
|
16
16
|
private let supportedNotifications: [String: String] = [
|
package/package.json
CHANGED
|
Binary file
|