genesys-cloud-messenger-mobile-sdk-rn-wrapper

所属分类:云原生工具
开发工具:kotlin
文件大小:0KB
下载次数:0
上传日期:2023-06-29 16:57:54
上 传 者sh-1993
说明:  为Genesys Cloud Messenger SDK提供简单 React本机包装器的SDK。,
(An SDK that provides a simple react native wrapper for the Genesys Cloud Messenger SDK.,)

文件列表:
Jenkinsfile (3543, 2023-06-29)
LICENSE (1085, 2023-06-29)
android/ (0, 2023-06-29)
android/build.gradle (5421, 2023-06-29)
android/gradle.properties (1216, 2023-06-29)
android/gradle/ (0, 2023-06-29)
android/gradle/wrapper/ (0, 2023-06-29)
android/gradle/wrapper/gradle-wrapper.jar (59203, 2023-06-29)
android/gradle/wrapper/gradle-wrapper.properties (202, 2023-06-29)
android/gradlew (5766, 2023-06-29)
android/gradlew.bat (2763, 2023-06-29)
android/src/ (0, 2023-06-29)
android/src/main/ (0, 2023-06-29)
android/src/main/AndroidManifest.xml (694, 2023-06-29)
android/src/main/java/ (0, 2023-06-29)
android/src/main/java/com/ (0, 2023-06-29)
android/src/main/java/com/genesys/ (0, 2023-06-29)
android/src/main/java/com/genesys/messenger/ (0, 2023-06-29)
android/src/main/java/com/genesys/messenger/GenesysCloud.kt (2692, 2023-06-29)
android/src/main/java/com/genesys/messenger/GenesysCloudChatActivity.kt (6854, 2023-06-29)
android/src/main/java/com/genesys/messenger/GenesysCloudPackage.kt (739, 2023-06-29)
android/src/main/res/ (0, 2023-06-29)
android/src/main/res/layout/ (0, 2023-06-29)
android/src/main/res/layout/fragment_layout.xml (1315, 2023-06-29)
android/src/main/res/menu/ (0, 2023-06-29)
android/src/main/res/menu/menu_main.xml (640, 2023-06-29)
android/src/main/res/values/ (0, 2023-06-29)
android/src/main/res/values/strings.xml (185, 2023-06-29)
genesys-cloud-messenger-mobile-sdk-rn-wrapper.podspec (711, 2023-06-29)
index.js (133, 2023-06-29)
ios/ (0, 2023-06-29)
ios/GenesysCloud.xcodeproj/ (0, 2023-06-29)
ios/GenesysCloud.xcodeproj/project.pbxproj (8709, 2023-06-29)
ios/GenesysCloudModule.h (297, 2023-06-29)
ios/GenesysCloudModule.m (4457, 2023-06-29)
package.json (785, 2023-06-29)

# genesys-cloud-messenger-mobile-sdk-rn-wrapper > Genesys Cloud Messaging SDK for React Native The SDK provides a simple react native wrapper for the Genesys Cloud Messenger SDK. **Author:** Genesys **Platform Support:** Android, iOS - [Getting Started](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#getting-started) - [Pre-Requisites](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#pre-requisites) - [Install](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#install) - [Update](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#update) - [Platform specific additional steps](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#platform-specific-additional-steps) - [Android](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#android) - [iOS](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#ios) - [Usage](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#usage) - [Import](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#import) - [Start Chat](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#start-chat) - [Chat Events](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#chat-events) - [Sample Application](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/https://github.com/genesys/MobileDxRNSample) - [License](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/#license) ## Getting Started ### Pre-requisites In order to use this SDK you need a Genesys account with the Messaging feature enabled. ### Install Run the following on the application root directory. - **Option 1 - `npm install`** ```sh npm install genesys-cloud-messenger-mobile-sdk-rn-wrapper --save ``` - **Option 2 - `yarn add`** ```sh yarn add genesys-cloud-messenger-mobile-sdk-rn-wrapper ``` - **Install Genesys chat module native dependency** ```sh react-native link genesys-cloud-messenger-mobile-sdk-rn-wrapper ``` ### Update To update your project to the latest version of `genesys-messenger-mobile-sdk-rn-wrapper` ```sh npm update genesys-cloud-messenger-mobile-sdk-rn-wrapper ``` ## Platform specific additional steps ### android In order to be able to use the chat module on android please follow the next steps. 1. Go to `build.gradle` file, on the android project of your react native app. ```cmd YourAppFolder ├── android │ ├── app │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ ├── build.gradle <--- │ ├── gradle │ │ └── wrapper │ ├── gradle.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle | ``` - Add the following repositories: ```gradle mavenCentral() maven {url "https://genesysdx.jfrog.io/artifactory/genesysdx-android.dev"} ``` ### ios In order to be able to use the chat module on iOS please follow the next steps. 1. Go to `Podfile` file, on the ios project of your react native app. ```cmd YourAppFolder ├── ios │ ├── Podfile <--- ``` - validate your platform is set to `iOS13` or above. ```ruby platform :ios, '13.0' ``` - Add Genesys Messeging SDK sources. ```ruby source 'https://github.com/genesys/dx-sdk-specs-dev' source 'https://github.com/CocoaPods/Specs' ``` - Add `use_frameworks!` inside `target` scope. - Add below `post_install` inside `target` scope. ```ruby target 'YourAppTargetName' do config = use_native_modules! use_frameworks! use_react_native!( :path => config[:reactNativePath], # to enable hermes on iOS, change `false` to `true` and then install pods :hermes_enabled => false ) post_install do |installer| react_native_post_install(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' end if (target.name&.eql?('FBReactNativeSpec')) target.build_phases.each do |build_phase| if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs')) target.build_phases.move(build_phase, 0) end end end end end end ``` >[Podfile Full Example](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/https://github.com/genesys/MobileDxRNSample/blob/master/ios/Podfile) - **Disable `Flipper` if activated.** ```ruby # use_flipper!() ``` 2 . Make sure you run `pod update genesys-cloud-messenger-mobile-sdk-rn-wrapper` to get latest version. ## Usage ### import Import `GenesysCloud` module. ```javascript import { NativeModules } from 'react-native'; const { GenesysCloud } = NativeModules; ``` ### start-chat Call `startChat` to get the messenging view and start conversation with an agent. ```javascript // Start a chat using the following line: GenesysCloud.startChat(deploymentId, domain, tokenStoreKey, logging); ``` ### chat-events The wrapper allows listenning to events raised on the chat. - Error events Error event has the following format: `{errorCode:"", reason:"", message:""}` - State events Currently only `started` and `ended` are supported. State event has the following format: `{state:""}` In order to register to chat events, add the following to your App: ```javascript import { DeviceEventEmitter, NativeEventEmitter } from 'react-native'; // Create event emitter to subscribe to chat events const eventEmitter = Platform.OS === 'android' ? DeviceEventEmitter : new NativeEventEmitter(GenesysCloud) //-> Before calling to startChat, make sure to subscribe to chat events. // Adds a listener to messenger chat errors. listeners['onMessengerError'] = eventEmitter.addListener('onMessengerError', (error) => {}); // Adds a listener to messenger chat state events. listeners['onMessengerState'] = eventEmitter.addListener('onMessengerState', (state)=>{}); //-> Once the chat was ended, the listeners should be removed. listeners['onMessengerError'].remove(); listeners['onMessengerState'].remove(); // E.g. Usage of the `ended` state event to remove chat listeners: const onStateChanged = (state) => { if(state.state == 'ended'){ Object.keys(listeners).forEach((key)=>{ const listener = listeners[key] console.log(`removing listener: ${key}`); if(listener) listener.remove(); }) } }; ``` #### Checkout [Sample Application](https://github.com/genesys/genesys-cloud-messenger-mobile-sdk-rn-wrapper/blob/master/https://github.com/genesys/MobileDxRNSample/blob/master/App.js) for more details --- ## Android ### Configure chat screen orientation Before `startChat` is called, use `GenesysCloud.requestScreenOrientation()` API to set the chat orientation to one of the available options provided by `GenesysCloud.getConstants()`. - SCREEN_ORIENTATION_PORTRAIT - SCREEN_ORIENTATION_LANDSCAPE - SCREEN_ORIENTATION_UNSPECIFIED - SCREEN_ORIENTATION_LOCKED ```javascript // E.g. GenesysCloud.requestScreenOrientation( GenesysCloud.getConstants().SCREEN_ORIENTATION_LOCKED) ``` ### MinifyEnabled and proguard rules If the hosting app is using the `minifyEnabled` on gradle configurations, the following line should be added to the `proguard-rules.pro` file: `-keep class com.genesys.cloud.messenger.transport.shyrka.** { *; }` ## License MIT

近期下载者

相关文件


收藏者