infobip-mobile-messaging-react-native-plugin 7.0.1 → 7.0.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 +5 -1
- package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMChatViewManager.java +5 -16
- package/infobip-mobile-messaging-react-native-plugin-7.0.3.tgz +0 -0
- package/infobip-mobile-messaging-react-native-plugin.podspec +3 -3
- package/package.json +2 -2
- package/src/components/RNMMChatViewNativeComponent.js +58 -0
- package/{index.d.ts → src/index.d.ts} +0 -0
- package/{index.js → src/index.js} +15 -82
- package/infobip-mobile-messaging-react-native-plugin-6.4.7.tgz +0 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ For iOS project:
|
|
|
22
22
|
For Android project:
|
|
23
23
|
- Android Studio (Bumblebee | 2021.1.1)
|
|
24
24
|
- Gradle (v7.3.3)
|
|
25
|
-
- Supported API Levels: 21 (Android 5.0 - [Lollipop](https://developer.android.com/about/versions/lollipop)) -
|
|
25
|
+
- Supported API Levels: 21 (Android 5.0 - [Lollipop](https://developer.android.com/about/versions/lollipop)) - 33 (Android 13.0)
|
|
26
26
|
|
|
27
27
|
## Quick start guide
|
|
28
28
|
|
|
@@ -96,6 +96,10 @@ This guide is designed to get you up and running with Mobile Messaging SDK plugi
|
|
|
96
96
|
> </manifest>
|
|
97
97
|
> ```
|
|
98
98
|
|
|
99
|
+
> ### Notice (when targeting Android 13):
|
|
100
|
+
> Starting from Android 13, Google requires to ask user for notification permission. Follow [this guide](https://github.com/infobip/mobile-messaging-react-native-plugin/wiki/Android-13-Notification-Permission-Handling) to make a permission request.
|
|
101
|
+
|
|
102
|
+
|
|
99
103
|
## Initialization configuration
|
|
100
104
|
|
|
101
105
|
Initialize Mobile Messaging React Native plugin, provide application configuration in init method:
|
package/android/src/main/java/org/infobip/reactlibrary/mobilemessaging/RNMMChatViewManager.java
CHANGED
|
@@ -8,17 +8,15 @@ import androidx.annotation.Nullable;
|
|
|
8
8
|
|
|
9
9
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
10
10
|
import com.facebook.react.bridge.ReadableArray;
|
|
11
|
-
import com.facebook.react.common.MapBuilder;
|
|
12
11
|
import com.facebook.react.uimanager.ThemedReactContext;
|
|
13
12
|
import com.facebook.react.uimanager.ViewGroupManager;
|
|
14
13
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
|
15
14
|
|
|
16
|
-
import java.util.Map;
|
|
17
|
-
|
|
18
15
|
class RNMMChatViewManager extends ViewGroupManager<ReactChatView> {
|
|
16
|
+
public static final String COMMAND_ADD = "add";
|
|
17
|
+
public static final String COMMAND_REMOVE = "remove";
|
|
18
|
+
|
|
19
19
|
public static final String VIEW_GROUP_MANAGER_NAME = "RNMMChatView";
|
|
20
|
-
public static final int COMMAND_ADD = 1;
|
|
21
|
-
public static final int COMMAND_REMOVE = 2;
|
|
22
20
|
private ReactApplicationContext context;
|
|
23
21
|
|
|
24
22
|
@Nullable
|
|
@@ -41,26 +39,17 @@ class RNMMChatViewManager extends ViewGroupManager<ReactChatView> {
|
|
|
41
39
|
return chatView;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
@Nullable
|
|
45
|
-
@Override
|
|
46
|
-
public Map<String, Integer> getCommandsMap() {
|
|
47
|
-
return MapBuilder.of(
|
|
48
|
-
"add", COMMAND_ADD,
|
|
49
|
-
"remove", COMMAND_REMOVE
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
42
|
@Override
|
|
54
43
|
public void receiveCommand(@NonNull ReactChatView root, String commandId, @Nullable ReadableArray args) {
|
|
55
44
|
super.receiveCommand(root, commandId, args);
|
|
56
|
-
|
|
45
|
+
|
|
57
46
|
if (args == null) {
|
|
58
47
|
Log.e(Utils.TAG, "RNMMChatViewManager received command without argumnents, Id: " + commandId);
|
|
59
48
|
return;
|
|
60
49
|
}
|
|
61
50
|
int reactNativeViewId = args.getInt(0);
|
|
62
51
|
|
|
63
|
-
switch (
|
|
52
|
+
switch (commandId) {
|
|
64
53
|
case COMMAND_ADD:
|
|
65
54
|
addChatFragment(root, reactNativeViewId);
|
|
66
55
|
break;
|
|
Binary file
|
|
@@ -19,8 +19,8 @@ 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.
|
|
22
|
+
s.dependency "MobileMessaging/Core", "10.7.0"
|
|
23
|
+
s.dependency "MobileMessaging/Geofencing", "10.7.0"
|
|
24
|
+
s.dependency "MobileMessaging/InAppChat", "10.7.0"
|
|
25
25
|
|
|
26
26
|
end
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infobip-mobile-messaging-react-native-plugin",
|
|
3
3
|
"title": "Infobip Mobile Messaging React Native Plugin",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.2",
|
|
5
5
|
"description": "Infobip Mobile Messaging React Native Plugin",
|
|
6
|
-
"main": "index.js",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
9
|
},
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React, { FC, useLayoutEffect, useRef } from "react";
|
|
3
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
4
|
+
import {findNodeHandle, requireNativeComponent} from 'react-native'
|
|
5
|
+
|
|
6
|
+
interface RNMMChatViewProps {
|
|
7
|
+
sendButtonColor: ?string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const RNMMChatViewCommands = codegenNativeCommands({
|
|
11
|
+
supportedCommands: ["add", "remove"],
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const ChatView: FC<RNMMChatViewProps> = props => {
|
|
15
|
+
const ref = useRef(null);
|
|
16
|
+
|
|
17
|
+
useLayoutEffect(() => {
|
|
18
|
+
// Not needed for iOS.
|
|
19
|
+
if (Platform.OS === "ios") return;
|
|
20
|
+
|
|
21
|
+
const chatViewRef = ref.current
|
|
22
|
+
// Nothing to do if there is no chatView reference.
|
|
23
|
+
if (!chatViewRef) return;
|
|
24
|
+
|
|
25
|
+
let addedViewId: ?number = null
|
|
26
|
+
|
|
27
|
+
// Fix for android, sometimes it can't get parent view, which is needed
|
|
28
|
+
// for proper relayout.
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
const viewId = findNodeHandle(chatViewRef);
|
|
31
|
+
if (viewId !== null && viewId !== undefined) {
|
|
32
|
+
RNMMChatViewCommands.add(chatViewRef, viewId);
|
|
33
|
+
console.log(`Adding android viewId: ${viewId}.`);
|
|
34
|
+
addedViewId = viewId;
|
|
35
|
+
}
|
|
36
|
+
}, 100);
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
const viewId = addedViewId
|
|
40
|
+
if (viewId !== null && viewId !== undefined) {
|
|
41
|
+
console.log(`Removing android viewId: ${viewId}.`);
|
|
42
|
+
RNMMChatViewCommands.remove(chatViewRef, viewId);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return <RNMMChatView {...props} ref={ref} />;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
ChatView.propTypes = {
|
|
51
|
+
/**
|
|
52
|
+
* Send button color can be set in hex format.
|
|
53
|
+
* If it's not provided, color from Infobip Portal widget configuration will be set.
|
|
54
|
+
*/
|
|
55
|
+
sendButtonColor: PropTypes.string,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const RNMMChatView = requireNativeComponent('RNMMChatView', ChatView);
|
|
File without changes
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EmitterSubscription,
|
|
4
3
|
NativeEventEmitter,
|
|
5
4
|
NativeModules,
|
|
5
|
+
Permission,
|
|
6
6
|
PermissionsAndroid,
|
|
7
|
-
Platform,
|
|
8
|
-
requireNativeComponent,
|
|
9
|
-
Text,
|
|
10
|
-
View,
|
|
11
|
-
findNodeHandle,
|
|
12
|
-
UIManager,
|
|
13
|
-
EmitterSubscription,
|
|
7
|
+
Platform,
|
|
14
8
|
} from 'react-native';
|
|
15
|
-
import type {Rationale} from
|
|
16
|
-
|
|
9
|
+
import type {Rationale} from 'react-native/Libraries/PermissionsAndroid/PermissionsAndroid';
|
|
10
|
+
|
|
17
11
|
|
|
18
12
|
const { ReactNativeMobileMessaging, RNMMChat } = NativeModules;
|
|
19
13
|
|
|
@@ -248,7 +242,7 @@ class MobileMessaging {
|
|
|
248
242
|
});
|
|
249
243
|
}
|
|
250
244
|
|
|
251
|
-
config.reactNativePluginVersion = require('
|
|
245
|
+
config.reactNativePluginVersion = require('../package').version;
|
|
252
246
|
|
|
253
247
|
ReactNativeMobileMessaging.init(config, onSuccess, onError);
|
|
254
248
|
};
|
|
@@ -437,21 +431,21 @@ class MobileMessaging {
|
|
|
437
431
|
}
|
|
438
432
|
|
|
439
433
|
return {
|
|
440
|
-
find
|
|
434
|
+
find (messageId, onSuccess, onError = function() {}) {
|
|
441
435
|
ReactNativeMobileMessaging.defaultMessageStorage_find(messageId, onSuccess, onError);
|
|
442
436
|
},
|
|
443
437
|
|
|
444
|
-
findAll
|
|
438
|
+
findAll (onSuccess, onError = function() {}) {
|
|
445
439
|
ReactNativeMobileMessaging.defaultMessageStorage_findAll(onSuccess, onError);
|
|
446
440
|
},
|
|
447
441
|
|
|
448
|
-
delete
|
|
442
|
+
delete (messageId, onSuccess = function() {}, onError = function() {}) {
|
|
449
443
|
ReactNativeMobileMessaging.defaultMessageStorage_delete(messageId, onSuccess, onError);
|
|
450
444
|
},
|
|
451
445
|
|
|
452
|
-
deleteAll
|
|
446
|
+
deleteAll (onSuccess = function() {}, onError = function() {}) {
|
|
453
447
|
ReactNativeMobileMessaging.defaultMessageStorage_deleteAll(onSuccess, onError);
|
|
454
|
-
}
|
|
448
|
+
},
|
|
455
449
|
};
|
|
456
450
|
};
|
|
457
451
|
|
|
@@ -459,7 +453,7 @@ class MobileMessaging {
|
|
|
459
453
|
* Displays built-in error dialog so that user can resolve errors during SDK initialization.
|
|
460
454
|
*
|
|
461
455
|
* @name showDialogForError
|
|
462
|
-
* @param {
|
|
456
|
+
* @param {Number} errorCode to display dialog for
|
|
463
457
|
* @param {Function} onSuccess will be called upon completion
|
|
464
458
|
* @param {Function} onError will be called on error
|
|
465
459
|
*/
|
|
@@ -653,67 +647,6 @@ class MobileMessaging {
|
|
|
653
647
|
|
|
654
648
|
}
|
|
655
649
|
|
|
656
|
-
export
|
|
657
|
-
androidViewId;
|
|
658
|
-
|
|
659
|
-
componentDidMount() {
|
|
660
|
-
if (Platform.OS === "ios") {
|
|
661
|
-
this.add();
|
|
662
|
-
} else {
|
|
663
|
-
//fix for android, sometimes it can't get parent view, which is needed for properly relayout
|
|
664
|
-
let _this = this;
|
|
665
|
-
setTimeout(function() { _this.add(); }, 100);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
componentWillUnmount() {
|
|
670
|
-
this.remove();
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
add = () => {
|
|
674
|
-
//not needed for iOS
|
|
675
|
-
if (Platform.OS === "ios") {
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
this.androidViewId = findNodeHandle(this.refs.rnmmChatViewRef);
|
|
679
|
-
console.log('Native android viewId: ', this.androidViewId);
|
|
680
|
-
|
|
681
|
-
UIManager.dispatchViewManagerCommand(
|
|
682
|
-
this.androidViewId,
|
|
683
|
-
UIManager.RNMMChatView.Commands.add.toString(),
|
|
684
|
-
[this.androidViewId],
|
|
685
|
-
);
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
remove = () => {
|
|
689
|
-
//not needed for iOS
|
|
690
|
-
if (Platform.OS === "ios") {
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
UIManager.dispatchViewManagerCommand(
|
|
694
|
-
this.androidViewId,
|
|
695
|
-
UIManager.RNMMChatView.Commands.remove.toString(),
|
|
696
|
-
[this.androidViewId],
|
|
697
|
-
);
|
|
698
|
-
};
|
|
699
|
-
|
|
700
|
-
render() {
|
|
701
|
-
return (
|
|
702
|
-
<RNMMChatView {...this.props}
|
|
703
|
-
ref="rnmmChatViewRef"
|
|
704
|
-
/>
|
|
705
|
-
);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
ChatView.propTypes = {
|
|
710
|
-
/**
|
|
711
|
-
* Send button color can be set in hex format.
|
|
712
|
-
* If it's not provided, color from Infobip Portal widget configuration will be set.
|
|
713
|
-
*/
|
|
714
|
-
sendButtonColor: PropTypes.string,
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
export let RNMMChatView = requireNativeComponent('RNMMChatView', ChatView);
|
|
650
|
+
export {ChatView, RNMMChatView} from './components/RNMMChatViewNativeComponent';
|
|
718
651
|
|
|
719
|
-
export
|
|
652
|
+
export const mobileMessaging = new MobileMessaging();
|
|
Binary file
|