tnrn_moxie
v2.0.7
Published
魔蝎数据
Downloads
12
Maintainers
Readme
魔蝎 SDK for [React Native][rn].
Getting Started
First, cd
to your RN project directory, and then install.
iOS
$ yarn add tnrn_moxie
# or:
$ npm install -S tnrn_moxie
# then:
$ react-native link tnrn_moxie
Manually
Add
node_modules/tnrn_moxie/ios/RNKitMoXie.xcodeproj
to your xcode project, usually under theLibraries
groupAdd
libRNKitMoXie.a
(fromProducts
underRNKitMoXie.xcodeproj
) to build target'sLinked Frameworks and Libraries
listAdd
-ObjC
toBuild Settings -> Other Linker Flags
Add
libz.tbd
toBuild phases -> Link Binary With Libraries
Open the access to albums (some operations need to scan a qrcode): goto
Info.plist
file and add the privacy key according to your requirement:Key: Privacy - Camera Usage Description Value: 需要您的同意,才能访问相册
Add image files to your main project: go to
Build phases -> Copy Bundle Resouces
, click the add button, and then choose the images fromnode_modules/RNKitMoXie/MoxieSDK/resouces
(TODO: add resouces from bundle)
Android
$ yarn add tnrn_moxie
# or:
$ npm install -S tnrn_moxie
# then:
$ react-native link tnrn_moxie
Manually
TODO:
Usage
example:
import { Platform } from 'react-native';
import RNKitMoXie from "tnrn_moxie";
import { DeviceEventEmitter, NativeEventEmitter } from 'react-native';
constructor(props) {
super(props);
this.moxieSubscription
this._initMoxie()
}
componentWillUnmount() {
if (this.moxieSubscription) {
// remember to remove
this.moxieSubscription.remove()
}
}
_initMoxie () {
RNKitMoXie.initial('user_id', 'api_key_value')
if (Platform.OS === 'ios') {
const moxieEmitter = new NativeEventEmitter(RNKitMoXie)
this.moxieSubscription = moxieEmitter.addListener('loginDone', (e) => {
this._callbackForMoxie(e)
})
} else {
DeviceEventEmitter.addListener('loginDone', function (e) {
this._callbackForMoxie(e)
})
}
}
_callbackForMoxie(e) {
console.log('receive functionName: ' + e.functionName)
}