react-native-plasma
v1.2.6
Published
React Native bridge for the Plasma SDK
Readme
react-native-plasma
React Native bridge for the Plasma mobile engagement SDK.
This package exposes native Android and iOS functionality to:
- initialize Plasma and manage user identity
- set tags and user properties
- fetch cached/live banner payloads
- fetch and acknowledge in-app popup deliveries
- show/hide native in-app popup UI from React Native
Installation
yarn add react-native-plasmaPeer dependencies used by the banner component:
yarn add react-native-gesture-handler react-native-reanimated react-native-reanimated-carouselFor iOS:
cd ios && pod installAvailable functionality
1) SDK lifecycle and user state
PlasmaAPI.initializePlasma(baseUrl, apiKey)PlasmaAPI.plasmaLogin(userId, deviceToken)PlasmaAPI.plasmaLogout()PlasmaAPI.setDeviceToken(token)PlasmaAPI.setUserId(userId)PlasmaAPI.setTags(tags)PlasmaAPI.setUserProps(props)
2) Banner APIs
PlasmaAPI.getBanners(onCacheRetrieved, onResponse)onCacheRetrievedreturns locally cached banners first (if any)onResponsereturns fresh network banners or an error
UI component:
PlasmaBannerCarousel
3) In-app popup APIs
PlasmaAPI.getInAppPopups(onSuccess, onError)PlasmaAPI.markInAppPopupViewed(deliveryId, metadata?, onSuccess?, onError?)PlasmaAPI.showInAppPopup(metadata?, limit?, onSuccess?, onError?)PlasmaAPI.hideInAppPopup()
UI component:
PlasmaInAppPopup(headless trigger component for native show/hide)
showInAppPopup displays native popup UI (Android/iOS) and supports metadata overrides such as button colors.
Basic usage
import { PlasmaAPI } from 'react-native-plasma';
PlasmaAPI.initializePlasma('https://your-domain.com', 'your-api-key');
PlasmaAPI.setUserId('person-123');
PlasmaAPI.setDeviceToken('fcm-or-apns-token');
PlasmaAPI.setTags({ city: 'Bangalore', tier: 'gold' });
PlasmaAPI.getInAppPopups(
(popups) => console.log('popups', popups),
(error) => console.warn(error)
);
PlasmaAPI.showInAppPopup(
{
buttonBackgroundColor: '#2563EB',
buttonTextColor: '#FFFFFF',
},
20,
() => console.log('popup shown'),
(error) => console.warn(error)
);Exports
PlasmaAPI(default export also available)PlasmaBannerCarouselPlasmaInAppPopup- Types:
RawBanner,InAppPopup,PlasmaInAppPopupProps,PlasmaBanner,PlasmaBannerCarouselProps
Local development
Use the bundled sample app under example/.
See example/README.md for contributor setup instructions.
