@flipgive/rn-button-sdk
v0.1.0
Published
rn wrapper for button sdk
Downloads
69
Readme
@flipgive/rn-button-sdk 🚀
React Native wrapper for Button SDK supporting both legacy and new architecture (TurboModules).
Installation 📦
npm install @flipgive/rn-button-sdk
# or
yarn add @flipgive/rn-button-sdk
Platform Setup 🛠️
Android Setup 🤖
- Add the Button SDK Application ID to your
AndroidManifest.xml
:
<application>
<!-- ... other config ... -->
<meta-data
android:name="com.usebutton.sdk.ApplicationId"
android:value="your-application-id" />
</application>
iOS Setup 🍎
- Add the Button SDK Application ID to your
Info.plist
:
<key>ButtonSdkAppId</key>
<string>your-application-id</string>
Usage 💻
import {
startPurchasePath,
clearAllData,
setIdentifier,
} from '@flipgive/rn-button-sdk';
// Start a purchase path
await startPurchasePath({
url: 'https://your-button-url.com',
token: 'your-token',
// Android only options ⚠️
headerTitle: 'Custom Title',
headerSubtitle: 'Custom Subtitle',
headerTitleColor: '#000000',
headerSubtitleColor: '#666666',
headerBackgroundColor: '#FFFFFF',
headerTintColor: '#808080',
footerBackgroundColor: '#FFFFFF',
footerTintColor: '#0000FF',
});
// Clear all Button SDK data
clearAllData();
// Set user identifier
setIdentifier('user-123');
Type Definitions 📝
export interface StartPurchasePathOptions {
url: string;
token: string;
// Android only options
headerTitle?: string;
headerSubtitle?: string;
headerTitleColor?: string;
headerSubtitleColor?: string;
headerBackgroundColor?: string;
headerTintColor?: string;
footerBackgroundColor?: string;
footerTintColor?: string;
}
export type Identifier = string;
Running the example 🏃♂️
- Install dependencies
nvm use
yarn install
- Update configuration
For Android: Modify example/android/app/src/main/AndroidManifest.xml
<meta-data
android:name="com.usebutton.sdk.ApplicationId"
android:value="your-application-id" />
For iOS: Modify example/ios/RnButtonSdkExample/Info.plist
<key>ButtonSdkAppId</key>
<string>your-application-id</string>
- Run the example
For Android:
yarn start
For iOS:
cd example/ios && pod install
yarn start
Architecture Support ⚡
This module supports both:
- Legacy architecture
- New architecture (TurboModules)
The module will automatically use the appropriate implementation based on your React Native configuration.
Notes 📝
- iOS implementation currently only supports
url
andtoken
parameters - Additional styling options are Android-only features
- Ensure you're using the correct Application ID for each platform
License 📄
MIT