infobip-mobile-messaging-react-native-plugin 8.0.2 → 8.2.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/android/build.gradle +8 -2
- package/android/infobip-mm-proguard-rules.pro +8 -1
- package/android/src/main/AndroidManifest.xml +18 -19
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ConfigCache.java +22 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/Configuration.java +5 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMChatModule.java +57 -2
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMWebRTCUI.java +129 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeMobileMessagingModule.java +1 -0
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/ReactNativeMobileMessagingPackage.java +2 -2
- package/infobip-mobile-messaging-react-native-plugin-8.1.0.tgz +0 -0
- package/infobip-mobile-messaging-react-native-plugin.podspec +6 -4
- package/ios/MobileMessagingPlugin/RNMMChat.swift +24 -4
- package/ios/MobileMessagingPlugin/RNMMChatBridge.m +2 -1
- package/ios/MobileMessagingPlugin/RNMMChatViewManager.swift +1 -1
- package/ios/MobileMessagingPlugin/RNMMWebRTCUI.swift +62 -0
- package/ios/MobileMessagingPlugin/RNMMWebRTCUIBridge.m +30 -0
- package/ios/MobileMessagingPlugin/RNMobileMessaging.swift +2 -2
- package/ios/MobileMessagingPlugin/RNMobileMessagingConfiguration.swift +4 -3
- package/ios/ReactNativeMobileMessaging.xcodeproj/project.pbxproj +8 -0
- package/package.json +1 -1
- package/src/index.d.ts +45 -7
- package/src/index.js +78 -6
- package/infobip-mobile-messaging-react-native-plugin-8.0.1.tgz +0 -0
package/android/build.gradle
CHANGED
|
@@ -11,6 +11,7 @@ def overrideGmsVersion = getRootProjectProperty('overrideGmsVersion', '')
|
|
|
11
11
|
def overrideFirebaseVersion = getRootProjectProperty('overrideFirebaseVersion', '')
|
|
12
12
|
def overrideKotlinVersion = getRootProjectProperty('overrideKotlinVersion', '')
|
|
13
13
|
def withCryptorMigration = getRootProjectProperty('withCryptorMigration', false)
|
|
14
|
+
def withWebRTCUI = getRootProjectProperty('withWebRTCUI', false)
|
|
14
15
|
|
|
15
16
|
apply plugin: 'com.android.library'
|
|
16
17
|
apply plugin: 'maven-publish'
|
|
@@ -85,14 +86,14 @@ repositories {
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
dependencies {
|
|
88
|
-
def mmVersion = '8.
|
|
89
|
+
def mmVersion = '8.2.0'
|
|
89
90
|
|
|
90
91
|
implementation 'com.facebook.react:react-native:+'
|
|
91
92
|
implementation "androidx.annotation:annotation:1.1.0"
|
|
92
93
|
|
|
93
94
|
implementation 'com.google.android.material:material:1.8.0'
|
|
94
95
|
implementation 'androidx.exifinterface:exifinterface:1.3.6'
|
|
95
|
-
implementation 'androidx.databinding:viewbinding:8.0.
|
|
96
|
+
implementation 'androidx.databinding:viewbinding:8.0.2'
|
|
96
97
|
|
|
97
98
|
implementation "com.infobip:infobip-mobile-messaging-android-resources:$mmVersion@aar"
|
|
98
99
|
implementation "com.infobip:infobip-mobile-messaging-android-chat-sdk:$mmVersion@aar"
|
|
@@ -111,6 +112,11 @@ dependencies {
|
|
|
111
112
|
exclude group: 'com.google.firebase', module: 'firebase-messaging'
|
|
112
113
|
}
|
|
113
114
|
}
|
|
115
|
+
if (withWebRTCUI.toBoolean()) {
|
|
116
|
+
implementation implementation("com.infobip:infobip-rtc-ui:$mmVersion") {
|
|
117
|
+
transitive = true
|
|
118
|
+
}
|
|
119
|
+
}
|
|
114
120
|
if (!overrideGmsVersion.empty) {
|
|
115
121
|
implementation "com.google.android.gms:play-services-location:$overrideGmsVersion"
|
|
116
122
|
}
|
|
@@ -11,4 +11,11 @@
|
|
|
11
11
|
|
|
12
12
|
# Application classes that will be serialized/deserialized over Gson
|
|
13
13
|
-keep class org.infobip.reactlibrary.mobilemessaging.Configuration* { *; }
|
|
14
|
-
-keep class org.infobip.reactlibrary.mobilemessaging.
|
|
14
|
+
-keep class org.infobip.reactlibrary.mobilemessaging.Configuration$* { *; }
|
|
15
|
+
-keep class org.infobip.reactlibrary.mobilemessaging.CacheManager* { *; }
|
|
16
|
+
|
|
17
|
+
# InfobipRtcUi classes that are accessed via reflection
|
|
18
|
+
-keep class com.infobip.webrtc.ui.InfobipRtcUi$Builder { *; }
|
|
19
|
+
-keep class com.infobip.webrtc.ui.SuccessListener { *; }
|
|
20
|
+
-keep class com.infobip.webrtc.ui.ErrorListener { *; }
|
|
21
|
+
-keep class com.infobip.webrtc.ui.InfobipRtcUi { *; }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
2
|
-
|
|
2
|
+
package="org.infobip.reactlibrary.mobilemessaging">
|
|
3
3
|
|
|
4
4
|
<!-- Mobile Messaging permissions -->
|
|
5
5
|
|
|
@@ -8,35 +8,34 @@
|
|
|
8
8
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
9
9
|
|
|
10
10
|
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
<permission
|
|
13
|
+
android:name="${applicationId}.permission.C2D_MESSAGE"
|
|
14
|
+
android:protectionLevel="signature" />
|
|
12
15
|
|
|
13
16
|
<!-- Needed for push notifications that contain VIBRATE flag. Optional, but recommended. -->
|
|
14
17
|
<uses-permission android:name="android.permission.VIBRATE" />
|
|
15
18
|
|
|
16
19
|
<!-- /Mobile Messaging permissions -->
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
<!-- Infobip rtc ui permissions -->
|
|
22
|
+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
23
|
+
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
|
24
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
25
|
+
<uses-permission android:name="android.permission.CAMERA" />
|
|
26
|
+
<!-- Infobip rtc ui permissions -->
|
|
19
27
|
|
|
28
|
+
<application>
|
|
20
29
|
<!-- Mobile Messaging components -->
|
|
21
|
-
|
|
22
30
|
<service
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
|
|
27
|
-
</intent-filter>
|
|
28
|
-
</service>
|
|
29
|
-
|
|
30
|
-
<service
|
|
31
|
-
android:name="org.infobip.mobile.messaging.cloud.MobileMessagingCloudService"
|
|
32
|
-
android:permission="android.permission.BIND_JOB_SERVICE"
|
|
33
|
-
android:exported="false" >
|
|
34
|
-
</service>
|
|
31
|
+
android:name="org.infobip.mobile.messaging.cloud.MobileMessagingCloudService"
|
|
32
|
+
android:permission="android.permission.BIND_JOB_SERVICE"
|
|
33
|
+
android:exported="false" />
|
|
35
34
|
|
|
36
35
|
<service
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
android:name="org.infobip.mobile.messaging.platform.MobileMessagingJobService"
|
|
37
|
+
android:enabled="false"
|
|
38
|
+
android:exported="false"
|
|
40
39
|
android:permission="android.permission.BIND_JOB_SERVICE" />
|
|
41
40
|
|
|
42
41
|
<receiver
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package org.infobip.reactlibrary.mobilemessaging;
|
|
2
|
+
|
|
3
|
+
public class ConfigCache {
|
|
4
|
+
private static final ConfigCache INSTANCE = new ConfigCache();
|
|
5
|
+
|
|
6
|
+
private Configuration configuration = null;
|
|
7
|
+
|
|
8
|
+
private ConfigCache() {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public static ConfigCache getInstance() {
|
|
12
|
+
return INSTANCE;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public Configuration getConfiguration() {
|
|
16
|
+
return configuration;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public void setConfiguration(Configuration configuration) {
|
|
20
|
+
this.configuration = configuration;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -41,6 +41,10 @@ class Configuration {
|
|
|
41
41
|
List<Action> actions;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
class WebRTCUI {
|
|
45
|
+
String applicationId;
|
|
46
|
+
}
|
|
47
|
+
|
|
44
48
|
AndroidConfiguration android;
|
|
45
49
|
String applicationCode;
|
|
46
50
|
boolean geofencingEnabled;
|
|
@@ -51,6 +55,7 @@ class Configuration {
|
|
|
51
55
|
String reactNativePluginVersion = "unknown";
|
|
52
56
|
PrivacySettings privacySettings = new PrivacySettings();
|
|
53
57
|
List<Category> notificationCategories = new ArrayList<Category>();
|
|
58
|
+
WebRTCUI webRTCUI;
|
|
54
59
|
|
|
55
60
|
@NonNull
|
|
56
61
|
static Configuration resolveConfiguration(JSONObject args) throws JSONException {
|
|
@@ -16,12 +16,44 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
|
16
16
|
import com.facebook.react.bridge.ReactMethod;
|
|
17
17
|
import com.facebook.react.bridge.ReadableMap;
|
|
18
18
|
|
|
19
|
+
import org.infobip.mobile.messaging.MobileMessaging;
|
|
19
20
|
import org.infobip.mobile.messaging.chat.InAppChat;
|
|
21
|
+
import org.infobip.mobile.messaging.mobileapi.MobileMessagingError;
|
|
22
|
+
import org.infobip.mobile.messaging.mobileapi.Result;
|
|
23
|
+
import org.infobip.mobile.messaging.util.StringUtils;
|
|
20
24
|
|
|
21
25
|
public class RNMMChatModule extends ReactContextBaseJavaModule implements ActivityEventListener, LifecycleEventListener {
|
|
22
26
|
|
|
27
|
+
private static final String EVENT_INAPPCHAT_JWT_REQUESTED = "inAppChat.jwtRequested";
|
|
28
|
+
|
|
23
29
|
private static ReactApplicationContext reactContext;
|
|
24
30
|
|
|
31
|
+
private String jwt = null;
|
|
32
|
+
private boolean isJwtProviderInitialInvocation = true;
|
|
33
|
+
private final InAppChat.JwtProvider jwtProvider = () -> {
|
|
34
|
+
if (!isJwtProviderInitialInvocation) {
|
|
35
|
+
//send event to JS to generate new JWT and invoke native setter, then wait 150ms and return generated JWT
|
|
36
|
+
ReactNativeEvent.send(EVENT_INAPPCHAT_JWT_REQUESTED, reactContext);
|
|
37
|
+
try {
|
|
38
|
+
Thread waitThread = new Thread(() -> {
|
|
39
|
+
try {
|
|
40
|
+
Thread.sleep(150);
|
|
41
|
+
} catch (InterruptedException e) {
|
|
42
|
+
Thread.currentThread().interrupt();
|
|
43
|
+
Log.e(Utils.TAG, "Thread Interrupted");
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
waitThread.start();
|
|
47
|
+
waitThread.join();
|
|
48
|
+
} catch (InterruptedException e) {
|
|
49
|
+
Thread.currentThread().interrupt();
|
|
50
|
+
Log.e(Utils.TAG, "Thread Interrupted");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
isJwtProviderInitialInvocation = false;
|
|
54
|
+
return this.jwt;
|
|
55
|
+
};
|
|
56
|
+
|
|
25
57
|
RNMMChatModule(ReactApplicationContext context) {
|
|
26
58
|
super(context);
|
|
27
59
|
reactContext = context;
|
|
@@ -56,8 +88,18 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
|
|
|
56
88
|
}
|
|
57
89
|
|
|
58
90
|
@ReactMethod
|
|
59
|
-
public void setLanguage(String localeString) {
|
|
60
|
-
InAppChat.getInstance(reactContext).setLanguage(localeString)
|
|
91
|
+
public void setLanguage(String localeString, final Callback onSuccess, final Callback onError) {
|
|
92
|
+
InAppChat.getInstance(reactContext).setLanguage(localeString, new MobileMessaging.ResultListener<String>() {
|
|
93
|
+
@Override
|
|
94
|
+
public void onResult(Result<String, MobileMessagingError> result) {
|
|
95
|
+
if (result.isSuccess()) {
|
|
96
|
+
onSuccess.invoke(result.getData());
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
onError.invoke(Utils.callbackError(result.getError().getMessage(), null));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
61
103
|
}
|
|
62
104
|
|
|
63
105
|
@ReactMethod
|
|
@@ -70,6 +112,19 @@ public class RNMMChatModule extends ReactContextBaseJavaModule implements Activi
|
|
|
70
112
|
}
|
|
71
113
|
}
|
|
72
114
|
|
|
115
|
+
@ReactMethod
|
|
116
|
+
public void setJwt(String jwt) {
|
|
117
|
+
this.jwt = jwt;
|
|
118
|
+
InAppChat inAppChat = InAppChat.getInstance(reactContext);
|
|
119
|
+
if (inAppChat.getJwtProvider() == null) {
|
|
120
|
+
inAppChat.setJwtProvider(jwtProvider);
|
|
121
|
+
this.isJwtProviderInitialInvocation = true;
|
|
122
|
+
}
|
|
123
|
+
else if (inAppChat.getJwtProvider() != null && StringUtils.isBlank(jwt)) {
|
|
124
|
+
inAppChat.setJwtProvider(null);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
73
128
|
@Override
|
|
74
129
|
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
|
|
75
130
|
FragmentActivity fragmentActivity = Utils.getFragmentActivity(reactContext);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
package org.infobip.reactlibrary.mobilemessaging;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.facebook.react.bridge.Callback;
|
|
9
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
11
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
13
|
+
|
|
14
|
+
import java.lang.reflect.Proxy;
|
|
15
|
+
|
|
16
|
+
public class RNMMWebRTCUI extends ReactContextBaseJavaModule {
|
|
17
|
+
private static Object infobipRtcUiInstance = null;
|
|
18
|
+
|
|
19
|
+
private Class<?> successListenerClass = null;
|
|
20
|
+
private Class<?> errorListenerClass = null;
|
|
21
|
+
|
|
22
|
+
public RNMMWebRTCUI(@Nullable ReactApplicationContext reactContext) {
|
|
23
|
+
super(reactContext);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@NonNull
|
|
27
|
+
@Override
|
|
28
|
+
public String getName() {
|
|
29
|
+
return "RNMMWebRTCUI";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactMethod
|
|
33
|
+
public void enableCalls(final Callback successCallback, final Callback errorCallback) {
|
|
34
|
+
try {
|
|
35
|
+
final Configuration configuration = ConfigCache.getInstance().getConfiguration();
|
|
36
|
+
if (configuration == null) {
|
|
37
|
+
errorCallback.invoke(Utils.callbackError("Mobile messaging not initialized. Please call mobileMessaging.init().", null));
|
|
38
|
+
} else if (configuration.webRTCUI != null && configuration.webRTCUI.applicationId != null) {
|
|
39
|
+
Class<?> rtcUiBuilderClass = Class.forName("com.infobip.webrtc.ui.InfobipRtcUi$Builder");
|
|
40
|
+
Object rtcUiBuilder = rtcUiBuilderClass.getDeclaredConstructor(Context.class).newInstance(getReactApplicationContext());
|
|
41
|
+
Object successListener = successListenerProxy(successCallback);
|
|
42
|
+
Object errorListener = errorListenerCallback(errorCallback);
|
|
43
|
+
rtcUiBuilderClass.getMethod("applicationId", String.class).invoke(rtcUiBuilder, configuration.webRTCUI.applicationId);
|
|
44
|
+
rtcUiBuilderClass.getMethod("enableInAppCalls", getSuccessListenerClass(), getErrorListenerClass()).invoke(
|
|
45
|
+
rtcUiBuilder,
|
|
46
|
+
successListener,
|
|
47
|
+
errorListener
|
|
48
|
+
);
|
|
49
|
+
infobipRtcUiInstance = rtcUiBuilderClass.getMethod("build").invoke(rtcUiBuilder);
|
|
50
|
+
} else {
|
|
51
|
+
errorCallback.invoke(Utils.callbackError("Configuration does not contain webRTCUI data.", null));
|
|
52
|
+
}
|
|
53
|
+
} catch (ClassNotFoundException e) {
|
|
54
|
+
errorCallback.invoke(Utils.callbackError("Android WebRtcUi not enabled. Please set flag buildscript {ext { withWebRTCUI = true } } in your build.gradle.", null));
|
|
55
|
+
} catch (ReflectiveOperationException e) {
|
|
56
|
+
errorCallback.invoke(Utils.callbackError("Cannot enable calls. " + e.getMessage(), null));
|
|
57
|
+
} catch (Throwable t) {
|
|
58
|
+
errorCallback.invoke(Utils.callbackError("Something went wrong. " + t.getMessage(), null));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@NonNull
|
|
63
|
+
private Class<?> getSuccessListenerClass() throws ClassNotFoundException {
|
|
64
|
+
if (successListenerClass == null)
|
|
65
|
+
successListenerClass = Class.forName("com.infobip.webrtc.ui.SuccessListener");
|
|
66
|
+
return successListenerClass;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@NonNull
|
|
70
|
+
private Class<?> getErrorListenerClass() throws ClassNotFoundException {
|
|
71
|
+
if (errorListenerClass == null)
|
|
72
|
+
errorListenerClass = Class.forName("com.infobip.webrtc.ui.ErrorListener");
|
|
73
|
+
return errorListenerClass;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@SuppressWarnings("SuspiciousInvocationHandlerImplementation")
|
|
77
|
+
@NonNull
|
|
78
|
+
private Object errorListenerCallback(Callback errorCallback) throws ClassNotFoundException {
|
|
79
|
+
return Proxy.newProxyInstance(
|
|
80
|
+
getClass().getClassLoader(),
|
|
81
|
+
new Class[]{getErrorListenerClass()},
|
|
82
|
+
(proxy, method, args) -> {
|
|
83
|
+
if (method.getName().equals("onError") && args.length > 0 && args[0] instanceof Throwable) {
|
|
84
|
+
Throwable throwable = (Throwable) args[0];
|
|
85
|
+
errorCallback.invoke(Utils.callbackError(throwable.getMessage(), null));
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@SuppressWarnings("SuspiciousInvocationHandlerImplementation")
|
|
93
|
+
@NonNull
|
|
94
|
+
private Object successListenerProxy(Callback successCallback) throws ClassNotFoundException {
|
|
95
|
+
return Proxy.newProxyInstance(
|
|
96
|
+
getClass().getClassLoader(),
|
|
97
|
+
new Class[]{getSuccessListenerClass()},
|
|
98
|
+
(proxy, method, args) -> {
|
|
99
|
+
if (method.getName().equals("onSuccess")) {
|
|
100
|
+
successCallback.invoke();
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactMethod
|
|
108
|
+
public void disableCalls(final Callback successCallback, final Callback errorCallback) {
|
|
109
|
+
if (infobipRtcUiInstance == null) {
|
|
110
|
+
errorCallback.invoke(Utils.callbackError("Calls are not enabled.", null));
|
|
111
|
+
} else {
|
|
112
|
+
try {
|
|
113
|
+
Class<?> infobipRtcUiClass = Class.forName("com.infobip.webrtc.ui.InfobipRtcUi");
|
|
114
|
+
infobipRtcUiClass.getMethod("disableCalls", getSuccessListenerClass(), getErrorListenerClass())
|
|
115
|
+
.invoke(
|
|
116
|
+
infobipRtcUiInstance,
|
|
117
|
+
successListenerProxy(successCallback),
|
|
118
|
+
errorListenerCallback(errorCallback)
|
|
119
|
+
);
|
|
120
|
+
} catch (ClassNotFoundException e) {
|
|
121
|
+
errorCallback.invoke(Utils.callbackError("Android WebRtcUi not enabled. Please set flag buildscript {ext { withWebRTCUI = true } } in your build.gradle.", null));
|
|
122
|
+
} catch (ReflectiveOperationException e) {
|
|
123
|
+
errorCallback.invoke(Utils.callbackError("Cannot disable calls. " + e.getMessage(), null));
|
|
124
|
+
} catch (Throwable t) {
|
|
125
|
+
errorCallback.invoke(Utils.callbackError("Something went wrong. " + t.getMessage(), null));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -369,6 +369,7 @@ public class ReactNativeMobileMessagingModule extends ReactContextBaseJavaModule
|
|
|
369
369
|
@ReactMethod
|
|
370
370
|
public void init(ReadableMap args, final Callback successCallback, final Callback errorCallback) throws JSONException {
|
|
371
371
|
final Configuration configuration = Configuration.resolveConfiguration(ReactNativeJson.convertMapToJson(args));
|
|
372
|
+
ConfigCache.getInstance().setConfiguration(configuration);
|
|
372
373
|
|
|
373
374
|
final Application context = (Application) reactContext.getApplicationContext();
|
|
374
375
|
|
|
@@ -4,7 +4,6 @@ import androidx.annotation.NonNull;
|
|
|
4
4
|
|
|
5
5
|
import java.util.ArrayList;
|
|
6
6
|
import java.util.Arrays;
|
|
7
|
-
import java.util.Collections;
|
|
8
7
|
import java.util.List;
|
|
9
8
|
|
|
10
9
|
import com.facebook.react.ReactPackage;
|
|
@@ -20,12 +19,13 @@ public class ReactNativeMobileMessagingPackage implements ReactPackage {
|
|
|
20
19
|
List<NativeModule> modules = new ArrayList<>();
|
|
21
20
|
modules.add(new ReactNativeMobileMessagingModule(reactContext));
|
|
22
21
|
modules.add(new RNMMChatModule(reactContext));
|
|
22
|
+
modules.add(new RNMMWebRTCUI(reactContext));
|
|
23
23
|
return modules;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
@NonNull
|
|
27
27
|
@Override
|
|
28
28
|
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
|
|
29
|
-
return Arrays
|
|
29
|
+
return Arrays.asList(new RNMMChatViewManager(reactContext));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
Binary file
|
|
@@ -19,8 +19,10 @@ Pod::Spec.new do |s|
|
|
|
19
19
|
s.requires_arc = true
|
|
20
20
|
|
|
21
21
|
s.dependency "React-Core"
|
|
22
|
-
s.dependency "MobileMessaging/Core", "10.
|
|
23
|
-
s.dependency "MobileMessaging/Geofencing", "10.
|
|
24
|
-
s.dependency "MobileMessaging/InAppChat", "10.
|
|
25
|
-
|
|
22
|
+
s.dependency "MobileMessaging/Core", "10.19.0"
|
|
23
|
+
s.dependency "MobileMessaging/Geofencing", "10.19.0"
|
|
24
|
+
s.dependency "MobileMessaging/InAppChat", "10.19.0"
|
|
25
|
+
if defined?($WebRTCUIEnabled)
|
|
26
|
+
s.dependency "MobileMessaging/WebRTCUI", "10.19.0"
|
|
27
|
+
end
|
|
26
28
|
end
|
|
@@ -48,13 +48,28 @@ class RNMMChat: NSObject {
|
|
|
48
48
|
@objc(setupChatSettings:)
|
|
49
49
|
func setupChatSettings(settings: NSDictionary) {
|
|
50
50
|
if let chatSettings = settings as? [String: AnyObject] {
|
|
51
|
-
|
|
51
|
+
MMChatSettings.settings.configureWith(rawConfig: chatSettings)
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
@objc(setLanguage:)
|
|
56
|
-
func setLanguage(localeString:
|
|
57
|
-
|
|
55
|
+
@objc(setLanguage:onSuccess:onError:)
|
|
56
|
+
func setLanguage(localeString: NSString, onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
57
|
+
guard let chatVC = RNMMChatView.viewController else {
|
|
58
|
+
MobileMessaging.inAppChat?.setLanguage(String(localeString))
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
let localeS = String(localeString)
|
|
62
|
+
let separator = localeS.contains("_") ? "_" : "-"
|
|
63
|
+
let components = localeS.components(separatedBy: separator)
|
|
64
|
+
let lang = MMLanguage.mapLanguage(from: components.first ??
|
|
65
|
+
String(localeS.prefix(2)))
|
|
66
|
+
chatVC.setLanguage(lang) { error in
|
|
67
|
+
if let error = error {
|
|
68
|
+
onError([error.reactNativeObject])
|
|
69
|
+
} else {
|
|
70
|
+
onSuccess(nil)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
58
73
|
}
|
|
59
74
|
|
|
60
75
|
@objc(sendContextualData:multiThreadStrategy:onSuccess:onError:)
|
|
@@ -70,4 +85,9 @@ class RNMMChat: NSObject {
|
|
|
70
85
|
}
|
|
71
86
|
}
|
|
72
87
|
}
|
|
88
|
+
|
|
89
|
+
@objc(setJwt:)
|
|
90
|
+
func setJwt(jwt: String) {
|
|
91
|
+
MobileMessaging.inAppChat?.jwt = jwt
|
|
92
|
+
}
|
|
73
93
|
}
|
|
@@ -20,7 +20,8 @@ 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
|
+
RCT_EXTERN_METHOD(setLanguage:(NSString *)data onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
24
|
+
RCT_EXTERN_METHOD(setJwt:)
|
|
24
25
|
RCT_EXTERN_METHOD(sendContextualData:(NSString *)data multiThreadStrategy:(BOOL)multiThreadStrategy onSuccess:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
25
26
|
RCT_EXTERN_METHOD(showThreadsList)
|
|
26
27
|
|
|
@@ -27,7 +27,7 @@ class RNMMChatViewManager: RCTViewManager {
|
|
|
27
27
|
weak static var viewController: MMChatViewController?
|
|
28
28
|
|
|
29
29
|
@objc func setSendButtonColor(_ colorString: NSString) {
|
|
30
|
-
|
|
30
|
+
MMChatSettings.settings.configureWith(rawConfig: ["sendButtonColor": colorString])
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
override func layoutSubviews() {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMMWebRTCUI.swift
|
|
3
|
+
// infobip-mobile-messaging-react-native-plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Francisco Fortes on 21.06.2022.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import MobileMessaging
|
|
10
|
+
|
|
11
|
+
@objc(RNMMWebRTCUI)
|
|
12
|
+
class RNMMWebRTCUI: NSObject {
|
|
13
|
+
|
|
14
|
+
@objc(enableCalls:onError:)
|
|
15
|
+
func enableCalls(onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
16
|
+
#if WEBRTCUI_ENABLED
|
|
17
|
+
if let cachedConfigDict = RNMobileMessagingConfiguration.getRawConfigFromDefaults(),
|
|
18
|
+
let configuration = RNMobileMessagingConfiguration(rawConfig: cachedConfigDict),
|
|
19
|
+
let webRTCUI = configuration.webRTCUI,
|
|
20
|
+
let webRTCId = webRTCUI[RNMobileMessagingConfiguration.Keys.applicationId] as? String {
|
|
21
|
+
MobileMessaging.webRTCService?.applicationId = webRTCId
|
|
22
|
+
MobileMessaging.webRTCService?.start({ result in
|
|
23
|
+
switch result {
|
|
24
|
+
case true:
|
|
25
|
+
MMLogDebug("[WebRTCUI] Request for enabling calls ended with success")
|
|
26
|
+
onSuccess(nil)
|
|
27
|
+
case false:
|
|
28
|
+
MMLogError("[WebRTCUI] Request for enabling calls ended with failure - See further logs.")
|
|
29
|
+
onError(nil)
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
} else {
|
|
33
|
+
MMLogDebug("[WebRTCUI] WebRTC's applicationId not defined in the configuration, calls were not enabled.")
|
|
34
|
+
onError([NSError(type: .InvalidArguments).reactNativeObject])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#else
|
|
38
|
+
MMLogDebug("[WebRTCUI] Not imported properly in podfile: library cannot be used.")
|
|
39
|
+
onError([NSError(type: .NotSupported).reactNativeObject])
|
|
40
|
+
#endif
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@objc(disableCalls:onError:)
|
|
44
|
+
func disableCalls(onSuccess: @escaping RCTResponseSenderBlock, onError: @escaping RCTResponseSenderBlock) {
|
|
45
|
+
#if WEBRTCUI_ENABLED
|
|
46
|
+
MobileMessaging.webRTCService?.stopService({ result in
|
|
47
|
+
switch result {
|
|
48
|
+
case true:
|
|
49
|
+
MMLogDebug("[WebRTCUI] Request for disabling calls ended with success")
|
|
50
|
+
onSuccess(nil)
|
|
51
|
+
case false:
|
|
52
|
+
MMLogError("[WebRTCUI] Request for disabling calls ended with failure - See further logs.")
|
|
53
|
+
onError(nil)
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
#else
|
|
57
|
+
MMLogError("[WebRTCUI] Not imported properly in podfile: library cannot be used")
|
|
58
|
+
onError([NSError(type: .NotSupported).reactNativeObject])
|
|
59
|
+
#endif
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
// RNMMChatBridge.m
|
|
3
|
+
// infobip-mobile-messaging-react-native-plugin
|
|
4
|
+
//
|
|
5
|
+
// Created by Olga Koroleva on 26.05.2020.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <React/RCTBridgeModule.h>
|
|
9
|
+
#import <React/RCTViewManager.h>
|
|
10
|
+
|
|
11
|
+
@interface RNMMWebRTCUI : NSObject
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@interface RNMMWebRTCUI (RCTExternModule) <RCTBridgeModule>
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
@implementation RNMMWebRTCUI (RCTExternModule)
|
|
18
|
+
RCT_EXPORT_MODULE_NO_LOAD(RNMMWebRTCUI, RNMMWebRTCUI)
|
|
19
|
+
RCT_EXTERN_METHOD(enableCalls:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
20
|
+
RCT_EXTERN_METHOD(disableCalls:(RCTResponseSenderBlock)successCallback onError:(RCTResponseSenderBlock)errorCallback)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
- (dispatch_queue_t)methodQueue {
|
|
24
|
+
return dispatch_get_main_queue();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
@end
|
|
@@ -119,10 +119,10 @@ class ReactNativeMobileMessaging: RCTEventEmitter {
|
|
|
119
119
|
MobileMessaging.privacySettings.carrierInfoSendingDisabled = configuration.privacySettings[RNMobileMessagingConfiguration.Keys.carrierInfoSendingDisabled].unwrap(orDefault: false)
|
|
120
120
|
MobileMessaging.privacySettings.userDataPersistingDisabled = configuration.privacySettings[RNMobileMessagingConfiguration.Keys.userDataPersistingDisabled].unwrap(orDefault: false)
|
|
121
121
|
|
|
122
|
-
var mobileMessaging = MobileMessaging.withApplicationCode(configuration.appCode, notificationType: configuration.notificationType
|
|
122
|
+
var mobileMessaging = MobileMessaging.withApplicationCode(configuration.appCode, notificationType: configuration.notificationType)
|
|
123
123
|
|
|
124
124
|
if configuration.geofencingEnabled {
|
|
125
|
-
|
|
125
|
+
mobileMessaging = mobileMessaging?.withGeofencingService()
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
if let storageAdapter = messageStorageAdapter, configuration.messageStorageEnabled {
|
|
@@ -19,7 +19,8 @@ class RNMobileMessagingConfiguration {
|
|
|
19
19
|
static let applicationCodePersistingDisabled = "applicationCodePersistingDisabled"
|
|
20
20
|
static let geofencingEnabled = "geofencingEnabled"
|
|
21
21
|
static let applicationCode = "applicationCode"
|
|
22
|
-
static let
|
|
22
|
+
static let webRTCUI = "webRTCUI"
|
|
23
|
+
static let applicationId = "applicationId"
|
|
23
24
|
static let logging = "logging"
|
|
24
25
|
static let defaultMessageStorage = "defaultMessageStorage"
|
|
25
26
|
static let notificationTypes = "notificationTypes"
|
|
@@ -31,11 +32,11 @@ class RNMobileMessagingConfiguration {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
let appCode: String
|
|
35
|
+
let webRTCUI: [String: AnyObject]?
|
|
34
36
|
let geofencingEnabled: Bool
|
|
35
37
|
let messageStorageEnabled: Bool
|
|
36
38
|
let defaultMessageStorage: Bool
|
|
37
39
|
let notificationType: MMUserNotificationType
|
|
38
|
-
let forceCleanup: Bool
|
|
39
40
|
let logging: Bool
|
|
40
41
|
let privacySettings: [String: Any]
|
|
41
42
|
let reactNativePluginVersion: String
|
|
@@ -51,8 +52,8 @@ class RNMobileMessagingConfiguration {
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
self.appCode = appCode
|
|
55
|
+
self.webRTCUI = rawConfig[RNMobileMessagingConfiguration.Keys.webRTCUI] as? [String: AnyObject]
|
|
54
56
|
self.geofencingEnabled = rawConfig[RNMobileMessagingConfiguration.Keys.geofencingEnabled].unwrap(orDefault: false)
|
|
55
|
-
self.forceCleanup = ios[RNMobileMessagingConfiguration.Keys.forceCleanup].unwrap(orDefault: false)
|
|
56
57
|
self.logging = ios[RNMobileMessagingConfiguration.Keys.logging].unwrap(orDefault: false)
|
|
57
58
|
self.defaultMessageStorage = rawConfig[RNMobileMessagingConfiguration.Keys.defaultMessageStorage].unwrap(orDefault: false)
|
|
58
59
|
self.messageStorageEnabled = rawConfig[RNMobileMessagingConfiguration.Keys.messageStorage] != nil ? true : false
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
A01DF5FD24802BDA00A65A31 /* RNMMChatViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A01DF5FB24802BDA00A65A31 /* RNMMChatViewManager.swift */; };
|
|
20
20
|
A01DF5FE24802BDA00A65A31 /* RNMMChatViewManagerBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = A01DF5FC24802BDA00A65A31 /* RNMMChatViewManagerBridge.m */; };
|
|
21
21
|
A069E87E23F417870065188B /* RNMobileMessagingStorageAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = A069E87D23F417870065188B /* RNMobileMessagingStorageAdapter.swift */; };
|
|
22
|
+
A867C79C2A4325AD00CF2C27 /* RNMMWebRTCUIBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = A867C79A2A4325AC00CF2C27 /* RNMMWebRTCUIBridge.m */; };
|
|
23
|
+
A867C79D2A4325AD00CF2C27 /* RNMMWebRTCUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = A867C79B2A4325AD00CF2C27 /* RNMMWebRTCUI.swift */; };
|
|
22
24
|
/* End PBXBuildFile section */
|
|
23
25
|
|
|
24
26
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -48,6 +50,8 @@
|
|
|
48
50
|
A01DF5FB24802BDA00A65A31 /* RNMMChatViewManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNMMChatViewManager.swift; sourceTree = "<group>"; };
|
|
49
51
|
A01DF5FC24802BDA00A65A31 /* RNMMChatViewManagerBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNMMChatViewManagerBridge.m; sourceTree = "<group>"; };
|
|
50
52
|
A069E87D23F417870065188B /* RNMobileMessagingStorageAdapter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RNMobileMessagingStorageAdapter.swift; sourceTree = "<group>"; };
|
|
53
|
+
A867C79A2A4325AC00CF2C27 /* RNMMWebRTCUIBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNMMWebRTCUIBridge.m; sourceTree = "<group>"; };
|
|
54
|
+
A867C79B2A4325AD00CF2C27 /* RNMMWebRTCUI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RNMMWebRTCUI.swift; sourceTree = "<group>"; };
|
|
51
55
|
CEEB052400B05B1AC8F953D0 /* Pods-ReactNativeMobileMessaging.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ReactNativeMobileMessaging.release.xcconfig"; path = "Target Support Files/Pods-ReactNativeMobileMessaging/Pods-ReactNativeMobileMessaging.release.xcconfig"; sourceTree = "<group>"; };
|
|
52
56
|
E00237C20633CB07301167F3 /* Pods_ReactNativeMobileMessaging.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ReactNativeMobileMessaging.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
53
57
|
/* End PBXFileReference section */
|
|
@@ -86,6 +90,8 @@
|
|
|
86
90
|
A036A57D24AA7A2600B426EF /* MobileMessagingPlugin */ = {
|
|
87
91
|
isa = PBXGroup;
|
|
88
92
|
children = (
|
|
93
|
+
A867C79B2A4325AD00CF2C27 /* RNMMWebRTCUI.swift */,
|
|
94
|
+
A867C79A2A4325AC00CF2C27 /* RNMMWebRTCUIBridge.m */,
|
|
89
95
|
A01DF5FB24802BDA00A65A31 /* RNMMChatViewManager.swift */,
|
|
90
96
|
A01DF5FC24802BDA00A65A31 /* RNMMChatViewManagerBridge.m */,
|
|
91
97
|
A01DF5F3247D2D6800A65A31 /* RNMMChat.swift */,
|
|
@@ -205,6 +211,7 @@
|
|
|
205
211
|
76D6D32D23915E1E00F1E02B /* RNMobileMessaging.swift in Sources */,
|
|
206
212
|
A006027D23E9586B007BE88B /* RNMobileMessagingErrorExtension.swift in Sources */,
|
|
207
213
|
A01DF5FE24802BDA00A65A31 /* RNMMChatViewManagerBridge.m in Sources */,
|
|
214
|
+
A867C79C2A4325AD00CF2C27 /* RNMMWebRTCUIBridge.m in Sources */,
|
|
208
215
|
A006029023E9AB3C007BE88B /* RNMobileMessagingUtils.swift in Sources */,
|
|
209
216
|
A01DF5F5247D2D6900A65A31 /* RNMMChat.swift in Sources */,
|
|
210
217
|
A006028E23E9AB27007BE88B /* RNMobileMessagingEventsManager.swift in Sources */,
|
|
@@ -213,6 +220,7 @@
|
|
|
213
220
|
76D6D32F239161D700F1E02B /* RNMobileMessagingBridge.m in Sources */,
|
|
214
221
|
A01DF5FD24802BDA00A65A31 /* RNMMChatViewManager.swift in Sources */,
|
|
215
222
|
A069E87E23F417870065188B /* RNMobileMessagingStorageAdapter.swift in Sources */,
|
|
223
|
+
A867C79D2A4325AD00CF2C27 /* RNMMWebRTCUI.swift in Sources */,
|
|
216
224
|
);
|
|
217
225
|
runOnlyForDeploymentPostprocessing = 0;
|
|
218
226
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infobip-mobile-messaging-react-native-plugin",
|
|
3
3
|
"title": "Infobip Mobile Messaging React Native Plugin",
|
|
4
|
-
"version": "8.0
|
|
4
|
+
"version": "8.2.0",
|
|
5
5
|
"description": "Infobip Mobile Messaging React Native Plugin",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"scripts": {
|
package/src/index.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ declare namespace MobileMessagingReactNative {
|
|
|
23
23
|
* The application code of your Application from Push Portal website
|
|
24
24
|
*/
|
|
25
25
|
applicationCode: string;
|
|
26
|
+
webRTCUI?: {
|
|
27
|
+
applicationId: string;
|
|
28
|
+
} | undefined;
|
|
26
29
|
geofencingEnabled?: boolean | undefined;
|
|
27
30
|
inAppChatEnabled?: boolean | undefined;
|
|
28
31
|
/**
|
|
@@ -32,7 +35,6 @@ declare namespace MobileMessagingReactNative {
|
|
|
32
35
|
defaultMessageStorage?: boolean | undefined;
|
|
33
36
|
ios?: {
|
|
34
37
|
notificationTypes?: string[] | undefined;
|
|
35
|
-
forceCleanup?: boolean | undefined;
|
|
36
38
|
logging?: boolean | undefined
|
|
37
39
|
} | undefined;
|
|
38
40
|
android?: {
|
|
@@ -467,36 +469,53 @@ declare namespace MobileMessagingReactNative {
|
|
|
467
469
|
*
|
|
468
470
|
* @param data contextual data in the form of JSON string
|
|
469
471
|
* @param allMultiThreadStrategy multi-thread strategy flag, true -> ALL, false -> ACTIVE
|
|
470
|
-
* @param {Function} onSuccess
|
|
471
|
-
* @param {Function} onError
|
|
472
|
+
* @param {Function} onSuccess success callback
|
|
473
|
+
* @param {Function} onError error callback
|
|
472
474
|
*/
|
|
473
|
-
sendContextualData(data: string, allMultiThreadStrategy: boolean, onSuccess: () => void, onError: (error:
|
|
475
|
+
sendContextualData(data: string, allMultiThreadStrategy: boolean, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
|
|
474
476
|
|
|
475
477
|
/**
|
|
476
478
|
* Set chat language
|
|
477
|
-
*
|
|
478
|
-
* @param localeString
|
|
479
|
+
* @name setLanguage
|
|
480
|
+
* @param localeString locale code to be set
|
|
481
|
+
* @param {Function} onSuccess success callback
|
|
482
|
+
* @param {Function} onError error callback
|
|
479
483
|
*/
|
|
480
|
-
setLanguage(localeString: string): void;
|
|
484
|
+
setLanguage(localeString: string, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
|
|
481
485
|
|
|
482
486
|
/**
|
|
483
487
|
* Returns unread in-app chat push messages counter.
|
|
484
488
|
* The counter increments each time the application receives in-app chat push message
|
|
485
489
|
* (this usually happens when chat screen is inactive or the application is in background/terminated state).
|
|
490
|
+
* @name getMessageCounter
|
|
491
|
+
* @param {Function} onResult message count callback
|
|
486
492
|
*/
|
|
487
493
|
getMessageCounter(onResult: (counter: number) => void): void;
|
|
488
494
|
|
|
489
495
|
/**
|
|
490
496
|
* MobileMessaging plugin automatically resets the counter to 0 whenever user opens the in-app chat screen.
|
|
491
497
|
* However, use the following API in case you need to manually reset the counter.
|
|
498
|
+
* @name resetMessageCounter
|
|
492
499
|
*/
|
|
493
500
|
resetMessageCounter(): void;
|
|
494
501
|
|
|
495
502
|
/**
|
|
496
503
|
* Navigates to THREAD_LIST view in multithread widget if in-app chat is shown as React Component.
|
|
504
|
+
* @name showThreadsList
|
|
497
505
|
*/
|
|
498
506
|
showThreadsList(): void;
|
|
499
507
|
|
|
508
|
+
/**
|
|
509
|
+
* Provides JSON Web Token (JWT), to give in-app chat ability to authenticate.
|
|
510
|
+
*
|
|
511
|
+
* In android app, function can be triggered multiple times during in-app chat lifetime, due to various events like screen orientation change, internet re-connection.
|
|
512
|
+
* If you can ensure JWT expiration time is longer than in-app chat lifetime, you can return cached token, otherwise it is important to provide fresh new token for each invocation.
|
|
513
|
+
*
|
|
514
|
+
* @name setJwtProvider
|
|
515
|
+
* @param {Function} jwtProvider callback returning JWT token
|
|
516
|
+
*/
|
|
517
|
+
setJwtProvider(jwtProvider: () => string): void;
|
|
518
|
+
|
|
500
519
|
/**
|
|
501
520
|
* This is used for requesting Location permissions for Android
|
|
502
521
|
* @param rationale rationale to display if it's needed. Describing why this permissions required.
|
|
@@ -514,3 +533,22 @@ declare namespace MobileMessagingReactNative {
|
|
|
514
533
|
}
|
|
515
534
|
|
|
516
535
|
declare var mobileMessaging: MobileMessagingReactNative.Api;
|
|
536
|
+
|
|
537
|
+
declare namespace WebRTCUI {
|
|
538
|
+
/**
|
|
539
|
+
* Manually enable WebRTCUI calls.
|
|
540
|
+
* @name enableCalls
|
|
541
|
+
* @param {Function} onSuccess success callback
|
|
542
|
+
* @param {Function} onError error callback
|
|
543
|
+
*/
|
|
544
|
+
enableCalls(onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Manually disable WebRTCUI calls if they were previously enabled. Note: This action may need up to half a minute to be completed,
|
|
548
|
+
* and calls may still be received in the meantime.
|
|
549
|
+
* @name disableCalls
|
|
550
|
+
* @param {Function} onSuccess success callback
|
|
551
|
+
* @param {Function} onError error callback
|
|
552
|
+
*/
|
|
553
|
+
disableCalls(onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
|
|
554
|
+
}
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import type {Rationale} from 'react-native/Libraries/PermissionsAndroid/PermissionsAndroid';
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const { ReactNativeMobileMessaging, RNMMChat } = NativeModules;
|
|
12
|
+
const { ReactNativeMobileMessaging, RNMMChat, RNMMWebRTCUI } = NativeModules;
|
|
13
13
|
|
|
14
14
|
export default ReactNativeMobileMessaging;
|
|
15
15
|
|
|
@@ -97,6 +97,7 @@ class MobileMessaging {
|
|
|
97
97
|
* - depersonalized
|
|
98
98
|
* - inAppChat.availabilityUpdated
|
|
99
99
|
* - inAppChat.unreadMessageCounterUpdated
|
|
100
|
+
* - inAppChat.viewStateChanged
|
|
100
101
|
*
|
|
101
102
|
* @name subscribe
|
|
102
103
|
* @param {String} eventName
|
|
@@ -135,12 +136,14 @@ class MobileMessaging {
|
|
|
135
136
|
* Configuration format:
|
|
136
137
|
* {
|
|
137
138
|
* applicationCode: '<The application code of your Application from Push Portal website>',
|
|
139
|
+
* webRTCUI: {
|
|
140
|
+
* applicationId: <String>
|
|
141
|
+
* },
|
|
138
142
|
* geofencingEnabled: true,
|
|
139
143
|
* messageStorage: '<Message storage save callback>',
|
|
140
144
|
* defaultMessageStorage: true,
|
|
141
145
|
* ios: {
|
|
142
146
|
* notificationTypes: ['alert', 'sound', 'badge'],
|
|
143
|
-
* forceCleanup: <Boolean>,
|
|
144
147
|
* logging: <Boolean>
|
|
145
148
|
* },
|
|
146
149
|
* android: {
|
|
@@ -543,18 +546,23 @@ class MobileMessaging {
|
|
|
543
546
|
* The predefined messages prompted within the In-app chat (such as status updates, button titles, input field prompt) by default are
|
|
544
547
|
* localized using system locale setting, but can be easily changed providing your locale string with the following formats:
|
|
545
548
|
* "es_ES", "es-ES" or "es"
|
|
549
|
+
* @name setLanguage
|
|
550
|
+
* @param localeString locale code to be set
|
|
551
|
+
* @param {Function} onSuccess success callback
|
|
552
|
+
* @param {Function} onError error callback
|
|
546
553
|
*/
|
|
547
|
-
setLanguage(localeString) {
|
|
548
|
-
RNMMChat.setLanguage(localeString);
|
|
554
|
+
setLanguage(localeString, onSuccess = function() {}, onError = function() {}) {
|
|
555
|
+
RNMMChat.setLanguage(localeString, onSuccess, onError);
|
|
549
556
|
};
|
|
550
557
|
|
|
551
558
|
/**
|
|
552
559
|
* Set contextual data of the widget
|
|
553
560
|
*
|
|
561
|
+
* @name sendContextualData
|
|
554
562
|
* @param data - contextual data in the form of JSON string
|
|
555
563
|
* @param allMultiThreadStrategy - multi-thread strategy flag, true -> ALL, false -> ACTIVE
|
|
556
|
-
* @param {Function} onSuccess
|
|
557
|
-
* @param {Function} onError
|
|
564
|
+
* @param {Function} onSuccess success callback
|
|
565
|
+
* @param {Function} onError error callback
|
|
558
566
|
*/
|
|
559
567
|
sendContextualData(data, allMultiThreadStrategy = false, onSuccess = function() {}, onError = function() {}) {
|
|
560
568
|
RNMMChat.sendContextualData(data, allMultiThreadStrategy, onSuccess, onError);
|
|
@@ -564,6 +572,8 @@ class MobileMessaging {
|
|
|
564
572
|
* Returns unread in-app chat push messages counter.
|
|
565
573
|
* The counter increments each time the application receives in-app chat push message
|
|
566
574
|
* (this usually happens when chat screen is inactive or the application is in background/terminated state).
|
|
575
|
+
* @name getMessageCounter
|
|
576
|
+
* @param {Function} onResult message count callback
|
|
567
577
|
*/
|
|
568
578
|
getMessageCounter(onResult) {
|
|
569
579
|
RNMMChat.getMessageCounter(onResult);
|
|
@@ -572,6 +582,7 @@ class MobileMessaging {
|
|
|
572
582
|
/**
|
|
573
583
|
* MobileMessaging plugin automatically resets the counter to 0 whenever user opens the in-app chat screen.
|
|
574
584
|
* However, use the following API in case you need to manually reset the counter.
|
|
585
|
+
* @name resetMessageCounter
|
|
575
586
|
*/
|
|
576
587
|
resetMessageCounter() {
|
|
577
588
|
RNMMChat.resetMessageCounter();
|
|
@@ -580,11 +591,44 @@ class MobileMessaging {
|
|
|
580
591
|
|
|
581
592
|
/**
|
|
582
593
|
* Navigates to THREAD_LIST view in multithread widget if in-app chat is shown as React Component.
|
|
594
|
+
* @name showThreadsList
|
|
583
595
|
*/
|
|
584
596
|
showThreadsList() {
|
|
585
597
|
RNMMChat.showThreadsList();
|
|
586
598
|
};
|
|
587
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Private global variable holding reference to android jwt update events subscription.
|
|
602
|
+
*/
|
|
603
|
+
#jwtSubscription = null;
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Provides JSON Web Token (JWT), to give in-app chat ability to authenticate.
|
|
607
|
+
*
|
|
608
|
+
* In android app, function can be triggered multiple times during in-app chat lifetime, due to various events like screen orientation change, internet re-connection.
|
|
609
|
+
* If you can ensure JWT expiration time is longer than in-app chat lifetime, you can return cached token, otherwise it is important to provide fresh new token for each invocation.
|
|
610
|
+
*
|
|
611
|
+
* @name setJwtProvider
|
|
612
|
+
* @param {Function} jwtProvider callback returning JWT token
|
|
613
|
+
*/
|
|
614
|
+
setJwtProvider(jwtProvider) {
|
|
615
|
+
const setJwt = () => {
|
|
616
|
+
RNMMChat.setJwt(jwtProvider());
|
|
617
|
+
};
|
|
618
|
+
setJwt();
|
|
619
|
+
|
|
620
|
+
if (Platform.OS === "android") {
|
|
621
|
+
if (jwtProvider != null) {
|
|
622
|
+
if (this.#jwtSubscription != null) {
|
|
623
|
+
this.unsubscribe(this.#jwtSubscription);
|
|
624
|
+
}
|
|
625
|
+
this.#jwtSubscription = this.subscribe('inAppChat.jwtRequested', () => {
|
|
626
|
+
setJwt();
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
588
632
|
/**
|
|
589
633
|
* Registering for POST_NOTIFICATIONS permission for Android 13+
|
|
590
634
|
*/
|
|
@@ -657,3 +701,31 @@ class MobileMessaging {
|
|
|
657
701
|
export {ChatView, RNMMChatView} from './components/RNMMChatViewNativeComponent';
|
|
658
702
|
|
|
659
703
|
export const mobileMessaging = new MobileMessaging();
|
|
704
|
+
|
|
705
|
+
class WebRTCUI {
|
|
706
|
+
/**
|
|
707
|
+
* Manually enable WebRTCUI calls, provided a valid application Id exists in the webRTCUI configuration. This function is used to control when to start
|
|
708
|
+
* calls, for example if you want to enabled it only after a successful user authentication. Note: Device settings, such as "Do not disturb" modes, will
|
|
709
|
+
* ignore this method until the operating system allows calls.
|
|
710
|
+
* @name enableCalls
|
|
711
|
+
* @param {Function} onSuccess success callback
|
|
712
|
+
* @param {Function} onError error callback
|
|
713
|
+
*/
|
|
714
|
+
enableCalls(onSuccess = function() {}, onError = function() {}){
|
|
715
|
+
RNMMWebRTCUI.enableCalls(onSuccess, onError);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Manually disable WebRTCUI calls. This function is used to control when to stop the calls, for example after a user log out. Note: This action may need
|
|
720
|
+
* up to half a minute to be completed, and calls may still be received in the meantime.
|
|
721
|
+
* @name disableCalls
|
|
722
|
+
* @param {Function} onSuccess success callback
|
|
723
|
+
* @param {Function} onError error callback
|
|
724
|
+
*/
|
|
725
|
+
disableCalls(onSuccess = function() {}, onError = function() {}) {
|
|
726
|
+
RNMMWebRTCUI.disableCalls(onSuccess, onError);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export const webRTCUI = new WebRTCUI();
|
|
Binary file
|