1
0
Fork 0
phizclip-react-native-demo/Readme.md

112 lines
3.8 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 深入小程序系列之三、 ReactNative和小程序混编
## 背景
ReactNative
:
![](./docs/mop-react-native-demo.gif)
## 环境搭建
```
npm install -g react-native-cli yarn
```
[](https://reactnative.dev/docs/environment-setup)已经有详细的说明,这里不再重复。大家可以看下我本地的环境配置版本,目前整个项目运行稳定,可以借鉴。
```bash
$ react-native info
info Fetching system and libraries information...
System:
OS: macOS 10.15.3
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Memory: 93.87 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.20.1 - ~/.nvm/versions/node/v10.20.1/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v10.20.1/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v10.20.1/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 26, 28, 29
Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.0
System Images: android-26 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
Languages:
Java: 10.0.1 - /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
*react-native*: Not Found
```
## 新建 ReactNative 样例工程
### 新建 ReactNative 工程
```bash
react-native init mopdemo
```
...
App iOS/Android
ReactNative iOS,Android Xcode AndroidStudio使
VSCode+Xcode
### 集成小程序解析引擎
10
1. package.json ReactNative
```javascript
"react-native-mopsdk": "^1.0.1"
```
2. main.dart Mop.instance.initialize sdkkey secrethttps://mp.finogeeks.com免费注册获取。注册使用方法可以参考[接入指引](https://mp.finogeeks.com/mop/document/introduce/access/mechanism.html)
```javascript
import MopSDK from 'react-native-mopsdk';
// 1. mop初始化
MopSDK.initialize({
appkey: '22LyZEib0gLTQdU3MUauASlb4KFRNRajt4RmY6UDSucA',
secret: '4a915e447bcbd439',
apiServer: 'https://mp.finogeeks.com',
apiPrefix: '/api/v1/mop'
}, (data) => {
console.log('message;', data);
});
```
3.
```javascript
MopSDK.openApplet('appid','','',(data)=>{});
```
* **SDKKEY** **Secret**
* **apiServer** `IP:`
* **id** ID()
* [https://mp.finogeeks.com](https://mp.finogeeks.com)快速注册,免费获取。
* **github** [https://github.com/finogeeks/mop-react-native-demo](https://github.com/finogeeks/mop-react-native-demo)