stonly-react-native
v1.0.7
Published
Stonly implementation for React-Native
Downloads
408
Readme
stonly-react-native
Stonly implementation for React Native
Installation
# npm
npm install stonly-react-native
# yarn
yarn add stonly-react-native
# pnpm
pnpm add stonly-react-native
# bun
bun add stonly-react-nativeExpo Configuration Plugin
For Expo projects, this package includes a configuration plugin that automatically sets up the necessary native code modifications.
Usage with Expo
- Add the plugin to your
app.config.jsorexpo.json:
// app.config.js
export default {
expo: {
// ... other config
plugins: [
[
"stonly-react-native/plugin",
{
widgetId: "your-widget-id-here",
iosUrlScheme: "your-ios-scheme", // optional
androidUrlScheme: "your-android-scheme", // optional
},
],
],
},
};Run
expo prebuildto apply the configuration.Build your app as usual.
What the plugin does
The plugin automatically configures your project by:
Android:
- Adding
StonlyReactNativeModule.Companion.setWidgetId()toMainApplication.kt - Adding
onResume()method with deep link handling toMainActivity.kt - Adding URL scheme to
AndroidManifest.xml(if provided)
iOS:
- Setting
Stonly.Widget.widgetIdinAppDelegate.swift(SDK 53+) orStonlyWidget.widgetIdinAppDelegate.mm(SDK 52 and below) - Adding URL handling with
Stonly.Widget.handleURL()inAppDelegate.swift(SDK 53+) orStonlyWidget.handleURL()inAppDelegate.mm(SDK 52 and below) - Adding URL scheme to
Info.plistCFBundleURLSchemes (if provided)
Manual Setup
If you're not using Expo or prefer manual setup, follow the platform-specific instructions below.
Android Setup
- Add to
MainApplication.kt:
import com.stonlyreactnative.StonlyReactNativeModule
// In onCreate method:
StonlyReactNativeModule.Companion.setWidgetId("your-widget-id", this);- Add to
MainActivity.kt:
import com.stonlyreactnative.StonlyReactNativeModule
override fun onResume() {
super.onResume()
StonlyReactNativeModule.Companion.register(getIntent())
}- Add URL scheme to
AndroidManifest.xml(optional):
<data android:scheme="your-url-scheme"/>iOS Setup
For Expo SDK 53+ (Swift AppDelegate)
- Add to
AppDelegate.swift:
import UIKit
import Stonly
// In application(_:didFinishLaunchingWithOptions:)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Stonly.Widget.widgetId = "your-widget-id"
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// Add URL handling method:
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
Stonly.Widget.handleURL(url)
return super.application(application, open: url, options: options)
}For Expo SDK 52 and below (Objective-C AppDelegate)
- Add to
AppDelegate.mm:
#import <Stonly/Stonly-Swift.h>
// In didFinishLaunchingWithOptions:
StonlyWidget.widgetId = @"your-widget-id";
// Add URL handling method:
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
[StonlyWidget handleURL:url];
return [RCTLinkingManager application:application openURL:url options:options];
}- Add URL scheme to
Info.plist(optional):
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>your-url-scheme</string>
</array>
</dict>
</array>Usage
After configuration, you can use the Stonly widget in your JavaScript code
