infobip-mobile-messaging-react-native-plugin 8.1.0 → 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 +6 -0
- 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/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/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 +23 -2
- package/src/index.js +32 -2
- package/infobip-mobile-messaging-react-native-plugin-8.0.2.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'
|
|
@@ -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 {
|
|
@@ -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
|
|
@@ -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.
|
|
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?: {
|
|
@@ -479,7 +481,7 @@ declare namespace MobileMessagingReactNative {
|
|
|
479
481
|
* @param {Function} onSuccess success callback
|
|
480
482
|
* @param {Function} onError error callback
|
|
481
483
|
*/
|
|
482
|
-
setLanguage(localeString: string, onSuccess: (
|
|
484
|
+
setLanguage(localeString: string, onSuccess: () => void, onError: (error: MobileMessagingError) => void): void;
|
|
483
485
|
|
|
484
486
|
/**
|
|
485
487
|
* Returns unread in-app chat push messages counter.
|
|
@@ -531,3 +533,22 @@ declare namespace MobileMessagingReactNative {
|
|
|
531
533
|
}
|
|
532
534
|
|
|
533
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
|
|
|
@@ -136,12 +136,14 @@ class MobileMessaging {
|
|
|
136
136
|
* Configuration format:
|
|
137
137
|
* {
|
|
138
138
|
* applicationCode: '<The application code of your Application from Push Portal website>',
|
|
139
|
+
* webRTCUI: {
|
|
140
|
+
* applicationId: <String>
|
|
141
|
+
* },
|
|
139
142
|
* geofencingEnabled: true,
|
|
140
143
|
* messageStorage: '<Message storage save callback>',
|
|
141
144
|
* defaultMessageStorage: true,
|
|
142
145
|
* ios: {
|
|
143
146
|
* notificationTypes: ['alert', 'sound', 'badge'],
|
|
144
|
-
* forceCleanup: <Boolean>,
|
|
145
147
|
* logging: <Boolean>
|
|
146
148
|
* },
|
|
147
149
|
* android: {
|
|
@@ -699,3 +701,31 @@ class MobileMessaging {
|
|
|
699
701
|
export {ChatView, RNMMChatView} from './components/RNMMChatViewNativeComponent';
|
|
700
702
|
|
|
701
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
|