@growth-rail/react-native 0.0.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +157 -4
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @growth-rail/react-native
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - React Native SDK implementation
8
+
3
9
  ## 0.0.0
4
10
 
5
11
  - Initial release of the React Native SDK.
package/README.md CHANGED
@@ -1,15 +1,168 @@
1
1
  # @growth-rail/react-native
2
2
 
3
- Growth Rail SDK for React Native.
3
+ The GrowthRail React Native SDK provides a seamless way to integrate referral programs into your React Native applications. It handles multi-platform deep linking, user attribution, and displays premium UI components for referral dashboards and banners.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **One-Tap Integration**: Wrap your app with `GrowthRailProvider` to get started.
8
+ - 🔗 **Deep Linking**: Built-in support for attribution via standard and deferred deep links.
9
+ - 🎨 **Premium UI**: Ready-made components for Referral Dashboards and Reward Banners.
10
+ - 📱 **Cross-Platform**: Consistent behavior across iOS and Android.
11
+ - ⚡ **Lightweight**: Optimized for performance with minimal dependencies.
4
12
 
5
13
  ## Installation
6
14
 
7
15
  ```bash
8
- npm install @growth-rail/react-native
16
+ yarn add @growth-rail/react-native @react-native-async-storage/async-storage react-native-play-install-referrer
9
17
  # or
10
- yarn add @growth-rail/react-native
18
+ npm install @growth-rail/react-native @react-native-async-storage/async-storage react-native-play-install-referrer
19
+ ```
20
+
21
+ > **Note**: For iOS, remember to run `cd ios && pod install`.
22
+
23
+ ## Setup
24
+
25
+ ### 1. Initialize the Provider
26
+
27
+ Wrap your main application component with `GrowthRailProvider`. This handles SDK initialization and provides the context for UI components.
28
+
29
+ ```tsx
30
+ import { GrowthRailProvider } from '@growth-rail/react-native';
31
+
32
+ const App = () => {
33
+ return (
34
+ <GrowthRailProvider
35
+ apiKey="YOUR_API_KEY"
36
+ userId="USER_UNIQUE_ID" // optional at start
37
+ >
38
+ <YourAppContent />
39
+ </GrowthRailProvider>
40
+ );
41
+ };
42
+ ```
43
+
44
+ ### 2. Deep Link Configuration
45
+
46
+ #### iOS (AppDelegate.mm)
47
+ Ensure your app handles deep links by adding the following to your `AppDelegate`:
48
+
49
+ ```objectivec
50
+ #import <React/RCTLinkingManager.h>
51
+
52
+ - (BOOL)application:(UIApplication *)application
53
+ openURL:(NSURL *)url
54
+ options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
55
+ {
56
+ return [RCTLinkingManager application:application openURL:url options:options];
57
+ }
58
+ ```
59
+
60
+ #### Android (AndroidManifest.xml)
61
+ Add an intent filter for your deep link scheme:
62
+
63
+ ```xml
64
+ <intent-filter>
65
+ <action android:name="android.intent.action.VIEW" />
66
+ <category android:name="android.intent.category.DEFAULT" />
67
+ <category android:name="android.intent.category.BROWSABLE" />
68
+ <data android:scheme="your-app-scheme" />
69
+ </intent-filter>
11
70
  ```
12
71
 
13
72
  ## Usage
14
73
 
15
- Please refer to the documentation for usage instructions.
74
+ ### User Initialization
75
+ If you didn't provide a `userId` to the provider, or if the user logs in later:
76
+
77
+ ```tsx
78
+ import { GrowthRail } from '@growth-rail/react-native';
79
+
80
+ const handleLogin = async (user) => {
81
+ await GrowthRail.initAppUser(user.id);
82
+ };
83
+ ```
84
+
85
+ ### Tracking Reward Events
86
+ Attribute successful actions (like purchases or sign-ups) to the referrer:
87
+
88
+ ```tsx
89
+ import { GrowthRail } from '@growth-rail/react-native';
90
+
91
+ const onPurchaseComplete = async () => {
92
+ await GrowthRail.trackRewardEvent('purchase_completed');
93
+ };
94
+ ```
95
+
96
+ ### Using the `useGrowthRail` Hook
97
+ For more control and to access loading/error states in your components:
98
+
99
+ ```tsx
100
+ import { useGrowthRail } from '@growth-rail/react-native';
101
+
102
+ const MyComponent = () => {
103
+ const {
104
+ initUser,
105
+ trackReward,
106
+ showReferralDashboard,
107
+ isLoading,
108
+ error
109
+ } = useGrowthRail();
110
+
111
+ const handleAction = async () => {
112
+ await trackReward('custom_action');
113
+ };
114
+
115
+ return (
116
+ <View>
117
+ <Button title="Open Referrals" onPress={() => showReferralDashboard()} />
118
+ {isLoading && <ActivityIndicator />}
119
+ </View>
120
+ );
121
+ };
122
+ ```
123
+
124
+ ### Referral Dashboard
125
+ Display a beautiful, pre-built dashboard for users to manage their referrals.
126
+
127
+ ```tsx
128
+ import { useGrowthRailContext } from '@growth-rail/react-native';
129
+
130
+ const MyProfile = () => {
131
+ const { showDashboard } = useGrowthRailContext();
132
+
133
+ return (
134
+ <Button title="Refer & Earn" onPress={() => showDashboard()} />
135
+ );
136
+ };
137
+ ```
138
+
139
+ ### Generating Referral Links Manually
140
+ If you need to build a custom UI, you can generate the referral link directly:
141
+
142
+ ```tsx
143
+ import { GrowthRail } from '@growth-rail/react-native';
144
+
145
+ const getLink = async () => {
146
+ const { referralLink } = await GrowthRail.createReferralLink();
147
+ console.log('Share this link:', referralLink);
148
+ };
149
+ ```
150
+
151
+ ## API Reference
152
+
153
+ ### `GrowthRailProvider` Props
154
+ | Prop | Type | Description |
155
+ | :--- | :--- | :--- |
156
+ | `apiKey` | `string` | Your GrowthRail API Key. |
157
+ | `userId` | `string` | (Optional) The current user's unique ID. |
158
+ | `apiUrl` | `string` | (Optional) Custom API endpoint. |
159
+
160
+ ### `useGrowthRailContext()`
161
+ Provides access to SDK methods:
162
+ - `showDashboard()`: Opens the referral dashboard.
163
+ - `hideDashboard()`: Closes the referral dashboard.
164
+ - `showFloatingButton()`: Shows/hides the floating trigger.
165
+ - `isInitialized`: Boolean indicating if the SDK is ready.
166
+
167
+ ## License
168
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-rail/react-native",
3
- "version": "0.0.0",
3
+ "version": "1.0.0",
4
4
  "description": "Growth Rail SDK for React Native",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",