MeiQia SDK for React Native
Getting started
$ npm install meiqia-react-native --save
or
$ yarn add meiqia-react-native
Mostly automatic installation
$ react-native link meiqia-react-native
iOS
- Select you app target on XCode and click the
Build Settings
tab. Go to theFramework Search Paths
section andadd
this new entry
and make sure it is set to$(SRCROOT)/../node_modules/meiqia-react-native/ios
recursive
- Select you app target on XCode and click the
Build Phases
tab. Go to theCopy Bundle Resources
section andadd
this new entrynode_modules/meiqia-react-native/ios/MeiQiaSDK/MQChatViewController/Assets/MQChatViewAsset.bundle
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜meiqia-react-native
and addRNMeiqia.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNMeiqia.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Select you app target on XCode and click the
Build Settings
tab. Go to theFramework Search Paths
section and add this new entry
and make sure it is set to$(SRCROOT)/../node_modules/meiqia-react-native/ios
recursive
- Select you app target on XCode and click the
Build Phases
tab. Go to theCopy Bundle Resources
section andadd
this new entrynode_modules/meiqia-react-native/ios/MeiQiaSDK/MQChatViewController/Assets/MQChatViewAsset.bundle
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.reactlibrary.RNMeiqiaPackage;
to the imports at the top of the file - Add
new RNMeiqiaPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':meiqia-react-native' project(':meiqia-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/meiqia-react-native/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':meiqia-react-native')
Usage
import
;
init appKey
;
launch chat window
;
or, if you known
;
Now, we can see the default chat window
APIs
MeiqiaInit
MeiqiaInit({param1, param2, ...});
param name | param type | default value | platform |
---|---|---|---|
appKey | string | required | all |
MeiqiaShow
MeiqiaShow({param1, param2, ...});
param name | param type | default value | platform |
---|---|---|---|
titleColor | string | '#000000' | iOS |
titleBarColor | string | '' | iOS |
naviColor | string | '' | iOS |
clientInfo | Object | {} | all |
customId | Object | {} | all |
clientId | Object | {} | all |
scheduledInfo | Object | {} | all |
MeiqiaStartService
MeiqiaStartService();
MeiqiaStopService
MeiqiaStopService();
MeiqiaRegisterDeviceToken
MeiqiaRegisterDeviceToken('xxxx-xxx-xxx');
NOTICE: This function only for iOS
Screenshot
Android
iOS
Debugging
iOS
Q: Why debugging on real device, the UI language is English?
In order to properly recognize the App's system language, you need to add a Localizations configuration. If you need to support English, Simplified Chinese, and Traditional Chinese, you need the following configuration in the Source Code of info.plist
:
CFBundleLocalizations zh_CN zh_TW en
or you also can run npm script: node ./node_modules/meiqia-react-native/ios-configuration.js YOUR_APP_NAME