# React Native Integration
Integration Sample Code
We provide a DEMO project. Developers can obtain the integration sample code from Github (International) (opens new window) or Gitee (Domestic) (opens new window).
# 1. Obtain Credentials
Please Note
To integrate the SDK, you must first create an application and bind a Mini-Program in the FinClip platform. After obtaining the application-specific SDK KEY and SDK SECRET, you can then fill in the corresponding parameters when integrating the SDK. When opening a Mini-Program, the SDK will automatically initialize and verify whether the SDK KEY, SDK SECRET, and BundleID (Application ID) are correct.
You can 【Click Here】 to see how to obtain the required SDK KEY and SDK SECRET. Please ensure the parameters filled in during SDK integration are correct; otherwise, the Mini-Program will fail to open.
# 2. Integrate the Plugin
# 2.1 Import the Plugin
Import the Mini-Program engine plugin.
Introduce the Mini-Program ReactNative plugin in the package.json file.
"react-native-mopsdk": "^1.0.4"
Install the plugin.
$ npm install react-native-mopsdk --save
$ react-native link react-native-mopsdk
# 2.2 Initialize the Engine
Note: For initialization methods with other configuration items, please refer to the documentation SDK Initialization.
import MopSDK from 'react-native-mopsdk';
// 1. Import NativeModules, NativeEventEmitter
import { NativeModules, NativeEventEmitter } from 'react-native';
// 2. mop initialization
const eventEmitter = new NativeEventEmitter(NativeModules.FINMopSDK);
let finStoreConfigA = new FinStoreConfig(
"22LyZEib0gLTQdU3MUauATBwgfnTCJjdr7FCnywmAEM=",
"bdfd76cae24d4313",
"https://api.finclip.com");
let finStoreConfigs = [finStoreConfigA];
let config = new Config(finStoreConfigs,{language:LanguageType.Chinese,userId:"1234567",debug:true,appletDebugMode:BOOLState.BOOLStateTrue}) ;
let uiConfig = new UIConfig({isHideClearCacheMenu:true});
let params = {
config: config,
uiConfig: uiConfig,
finMopSDK: NativeModules.FINMopSDK,
nativeEventEmitter: eventEmitter
}
MopSDK.initSDK(params).then((res) => {
console.log('message: ', res);
const s = JSON.stringify(res);
this.setState({
status: 'native callback received',
message: s,
});
}).catch((error) => {
console.log('init error: ', error);
const s = 'initialize fail'
this.setState({
status: 'native callback received',
message: s,
});
})
# 2.3 Open a Mini-Program
MopSDK.startApplet({appletId:'64c23309c533620001a1971e', startParams:startParams, reLaunchMode: mode})