react-native-shoplive-module
v0.2.0
Published
personal adapter
Downloads
17
Readme
Shoplive module for react native for easier integration
Documentation
- download module by running :
npm install react-native-shoplive-module
1-2. run pod install in ios folder to install dependencies
pod install --repo-update
- Import modules and create instance
import {ShopliveJSModule} from "react-native-shoplive-module";
import type {EventData} from "react-native-shoplive-module";
const shoplive = new ShopliveJSModule();
- Run campaign by setting accessKey and playing with campaignKey
shoplive.setAccessKey(ACCESSKEY);
shoplive.play(CAMPAIGNKEY);
- Add handlers to define your custom action upon each event
shoplive.onHandleNavigation((payload: EventData) => {
console.log('addhandleNavigationEventListener ', payload);
});
shoplive.onDownloadCoupon((payload: EventData) => {
console.log('addDownloadCouponEventListener ', payload);
});
shoplive.onReceivedCommand((payload: EventData) => {
console.log('onReceivedCommand ', payload);
if ('command' in payload) {
const data = JSON.parse(payload.data);
switch (payload.command) {
case 'CLICK_PRODUCT_DETAIL':
//need to check the payload!!!!!!ios!!!!!!!!!!!!
if ('url' in data) console.log('click on product:', data.url);
break;
}
}
});
shoplive.onError((payload: EventData) => {
console.log('onError hahahaha', payload);
});
shoplive.onPlayerClosing((payload: EventData) => {
console.log('onPlayerClosing hahahaha', payload);
if (Platform.OS === 'ios') {
console.log(`player is chaging to PIP / or being closed`);
} else if (Platform.OS === 'android') {
console.log(`playerClosing`);
}
});
shoplive.onPlayerDestroyed((payload: EventData) => {
console.log('onPlayerDestroyed hahahaha', payload);
if (Platform.OS === 'ios') {
console.log(`player has changed to PIP / or has closed`);
} else if (Platform.OS === 'android') {
console.log(`player closed`);
}
});
shoplive.onPlayerCreated((payload: EventData) => {
console.log('onPlayerCreated', payload);
});
Demo Apps
The /example
directory contains the demo app
Made with create-react-native-library