rn-linkrunner 1.1.2 → 2.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.
@@ -0,0 +1,23 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'LinkrunnerSDK'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.authors = { "Linkrunner" => "support@linkrunner.io" }
14
+ s.platforms = { :ios => "15.0" }
15
+ s.swift_version = '5.0'
16
+ s.source = { :git => package['repository']['url'].gsub('git+', ''), :tag => "#{s.version}" }
17
+
18
+ s.source_files = "ios/*.{h,c,m,swift}"
19
+ s.requires_arc = true
20
+
21
+ s.dependency "React"
22
+ s.dependency 'LinkrunnerKit', '3.0.1'
23
+ end
package/README.md CHANGED
@@ -1,303 +1,16 @@
1
- # rn-linkrunner
1
+ # Linkrunner React Native SDK
2
2
 
3
- React Native Package for [linkrunner.io](https://www.linkrunner.io)
3
+ A native React Native SDK for integrating Linkrunner functionality into your React Native applications.
4
4
 
5
- ## Table of Contents
5
+ ## Requirements
6
+ - React Native 0.70.0 and above
7
+ - iOS 15.0+ / Android 5.0 (API level 21) and above
6
8
 
7
- - [Installation](#installation)
8
- - [Step 1: Prerequisites](#step-1-prerequisites)
9
- - [Step 2: Installing rn-linkrunner](#step-2-installing-rn-linkrunner)
10
- - [Expo](#expo)
11
- - [Usage](#usage)
12
- - [Initialisation](#initialisation)
13
- - [Signup](#signup)
14
- - [Set User Data](#set-user-data)
15
- - [Trigger Deeplink](#trigger-deeplink-for-deferred-deep-linking)
16
- - [Track Event](#track-event)
17
- - [Process Google Analytics](#process-google-analytics)
18
- - [Capture Payment](#capture-payment)
19
- - [Remove Payment](#remove-payment)
20
- - [Support](#facing-issues-during-integration)
21
- - [License](#license)
22
-
23
- ## Installation
24
-
25
- ### Step 1: Prerequisites
26
-
27
- rn-linkrunner also uses `react-native-device-info`, `@react-native-community/netinfo`, `@react-native-async-storage/async-storage`, `react-native-play-install-referrer` and `@sparkfabrik/react-native-idfa-aaid`. You can install these packages with the following command:
28
-
29
- ```sh
30
- npm install react-native-device-info @react-native-community/netinfo @react-native-async-storage/async-storage react-native-play-install-referrer @sparkfabrik/react-native-idfa-aaid
31
- ```
32
-
33
- or
34
-
35
- ```sh
36
- yarn add react-native-device-info @react-native-community/netinfo @react-native-async-storage/async-storage react-native-play-install-referrer @sparkfabrik/react-native-idfa-aaid
37
- ```
38
-
39
- **IOS Configuration**:
40
-
41
- - Run `cd ios && pod install` to install pods for the package.
42
- - Add the below code in `info.plist`:
43
- ```sh
44
- <key>NSUserTrackingUsageDescription</key>
45
- <string>This identifier will be used to deliver personalized ads and improve your app experience.</string>
46
- ```
47
-
48
- ### Step 2: Installing rn-linkrunner
49
-
50
- ```sh
51
- npm install rn-linkrunner
52
- ```
53
-
54
- or
55
-
56
- ```sh
57
- yarn add rn-linkrunner
58
- ```
59
-
60
- ## Expo
61
-
62
- If you are using Expo, you will need to use development builds since this package relies on native libraries. Follow the [Expo Development Builds Documentation](https://docs.expo.dev/develop/development-builds/introduction/) to get started.
63
-
64
- ## Usage
65
-
66
- ### Initialisation
67
-
68
- You'll need your [project token](https://www.linkrunner.io/dashboard?m=documentation) to initialise the package. Place this initialization step in your `App.tsx` component, making sure the dependency array is empty for the `useEffect`:
69
-
70
- ```js
71
- import linkrunner from 'rn-linkrunner';
72
- import analytics from '@react-native-firebase/analytics';
73
- import { Platform } from 'react-native';
74
-
75
- // Inside your react component
76
- useEffect(() => {
77
- init();
78
- }, []);
79
-
80
- const init = async () => {
81
- const initData = await linkrunner.init('PROJECT_TOKEN');
82
-
83
- // Call processGoogleAnalytics right after init
84
- if (Platform.OS === 'android') {
85
- await linkrunner.processGoogleAnalytics(analytics);
86
- }
87
- };
88
- ```
89
-
90
- #### Response type for `linkrunner.init`
91
-
92
- ```
93
- {
94
- ip_location_data: {
95
- ip: string;
96
- city: string;
97
- countryLong: string;
98
- countryShort: string;
99
- latitude: number;
100
- longitude: number;
101
- region: string;
102
- timeZone: string;
103
- zipCode: string;
104
- };
105
- deeplink: string;
106
- root_domain: boolean;
107
- campaign_data: {
108
- id: string;
109
- name: string;
110
- type: "ORGANIC" | "INORGANIC";
111
- ad_network: "META" | "GOOGLE" | null;
112
- group_name: string | null;
113
- asset_group_name: string | null;
114
- asset_name: string | null;
115
- };
116
- }
117
- ```
118
-
119
- ### Signup
120
-
121
- Call this function only once after the user has completed the onboarding process in your app. This should be triggered at the final step of your onboarding flow to register the user with Linkrunner.
122
-
123
- ```jsx
124
- import linkrunner from 'rn-linkrunner';
125
-
126
- const onSignup = async () => {
127
- const signup = await linkrunner.signup({
128
- user_data: {
129
- id: '1',
130
- name: 'John Doe', // optional
131
- phone: '9583849238', // optional
132
- email: 'support@linkrunner.io', //optional
133
- },
134
- data: {}, // Any other data you might need
135
- });
136
- };
137
- ```
138
-
139
- #### Response type for `linkrunner.signup`
140
-
141
- ```
142
- {
143
- ip_location_data: {
144
- ip: string;
145
- city: string;
146
- countryLong: string;
147
- countryShort: string;
148
- latitude: number;
149
- longitude: number;
150
- region: string;
151
- timeZone: string;
152
- zipCode: string;
153
- };
154
- deeplink: string;
155
- root_domain: boolean;
156
- }
157
- ```
158
-
159
- ### Set User Data
160
-
161
- Call this function everytime the app is opened and the user is logged in.
162
-
163
- ```jsx
164
- import linkrunner from 'rn-linkrunner';
165
-
166
- const setUserData = async () => {
167
- await linkrunner.setUserData({
168
- user_data: {
169
- id: '1',
170
- name: 'John Doe', // optional
171
- phone: '9583849238', // optional
172
- email: 'support@linkrunner.io', //optional
173
- },
174
- });
175
- };
176
- ```
177
-
178
- ### Trigger Deeplink (For Deferred Deep Linking)
179
-
180
- This function triggers the original deeplink that led to the app installation. Call it only after your main navigation is initialized and all deeplink-accessible screens are ready to receive navigation events.
181
-
182
- Note: For this to work properly make sure you have added verification objects on the [Linkrunner Dashboard](https://www.linkrunner.io/settings?sort_by=activity-1&s=store-verification).
183
-
184
- ```jsx
185
- import linkrunner from 'rn-linkrunner';
186
-
187
- const onTriggerDeeplink = async () => {
188
- await linkrunner.triggerDeeplink();
189
- };
190
- ```
191
-
192
- ### Track Event
193
-
194
- Use this method to track custom events
195
-
196
- ```js
197
- const trackEvent = async () => {
198
- await linkrunner.trackEvent(
199
- 'event_name', // Name of the event
200
- { key: 'value' } // Optional: Additional JSON data for the event
201
- );
202
- };
203
- ```
204
-
205
- ### Process Google Analytics
206
-
207
- Use this method to track GCLID from install referrer in Google Analytics. This is especially useful for tracking the effectiveness of Google Ads campaigns. For best results, call this method immediately after initializing linkrunner.
208
-
209
- ```js
210
- import analytics from '@react-native-firebase/analytics';
211
- import linkrunner from 'rn-linkrunner';
212
-
213
- // Recommended implementation
214
- const init = async () => {
215
- const initData = await linkrunner.init('PROJECT_TOKEN');
216
-
217
- // Call processGoogleAnalytics right after init
218
- linkrunner.processGoogleAnalytics(analytics);
219
- };
220
- ```
221
-
222
- #### Prerequisites for `linkrunner.processGoogleAnalytics`
223
-
224
- You must have `@react-native-firebase/analytics` installed in your project and have properly configured Firebase in your app according to the [Firebase for React Native documentation](https://rnfirebase.io/analytics/usage).
225
-
226
- ### Capture Payment
227
-
228
- Use this method to capture payment information:
229
-
230
- ```js
231
- const capturePayment = async () => {
232
- await linkrunner.capturePayment({
233
- amount: 100, // Payment amount
234
- userId: 'user123', // User identifier
235
- paymentId: 'payment456', // Optional: Unique payment identifier
236
- type: 'FIRST_PAYMENT', // Optional: Payment type
237
- status: 'PAYMENT_COMPLETED', // Optional: Payment status
238
- });
239
- };
240
- ```
241
-
242
- #### Parameters for `linkrunner.capturePayment`
243
-
244
- - `amount`: number (required) - The payment amount
245
- - `userId`: string (required) - Identifier for the user making the payment
246
- - `paymentId`: string (optional) - Unique identifier for the payment
247
- - `type`: string (optional) - Type of payment. Available options:
248
- - `FIRST_PAYMENT` - First payment made by the user
249
- - `WALLET_TOPUP` - Adding funds to a wallet
250
- - `FUNDS_WITHDRAWAL` - Withdrawing funds
251
- - `SUBSCRIPTION_CREATED` - New subscription created
252
- - `SUBSCRIPTION_RENEWED` - Subscription renewal
253
- - `ONE_TIME` - One-time payment
254
- - `RECURRING` - Recurring payment
255
- - `DEFAULT` - Default type (used if not specified)
256
- - `status`: string (optional) - Status of the payment. Available options:
257
- - `PAYMENT_INITIATED` - Payment has been initiated
258
- - `PAYMENT_COMPLETED` - Payment completed successfully (default if not specified)
259
- - `PAYMENT_FAILED` - Payment attempt failed
260
- - `PAYMENT_CANCELLED` - Payment was cancelled
261
-
262
- ### Remove Payment
263
-
264
- Use this method to remove a captured payment:
265
-
266
- ```js
267
- const removePayment = async () => {
268
- await linkrunner.removePayment({
269
- userId: 'user123', // User identifier
270
- paymentId: 'payment456', // Optional: Unique payment identifier
271
- });
272
- };
273
- ```
274
-
275
- #### Parameters for `linkrunner.removePayment`
276
-
277
- - `userId`: string (required) - Identifier for the user whose payment is being removed
278
- - `paymentId`: string (optional) - Unique identifier for the payment to be removed
279
-
280
- Note: Either `paymentId` or `userId` must be provided when calling `removePayment`. If `userId` is provided, all payments for that user will be removed.
281
-
282
- ### Function Placement Guide
283
-
284
- Below is a simple guide on where to place each function in your application:
285
-
286
- | Function | Where to Place | When to Call |
287
- | --------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -------------------------------------------------------- |
288
- | [`linkrunner.init`](#initialisation) | In your `App.tsx` within a `useEffect` hook with empty dependency array | Once when the app starts |
289
- | [`linkrunner.processGoogleAnalytics`](#process-google-analytics) | Just below the `linkrunner.init` function call in your `App.tsx` | Once after initializing linkrunner |
290
- | [`linkrunner.signup`](#signup) | In your onboarding flow | Once after user completes the onboarding process |
291
- | [`linkrunner.setUserData`](#set-user-data) | In your authentication logic | Every time the app is opened and the user is logged in |
292
- | [`linkrunner.triggerDeeplink`](#trigger-deeplink-for-deferred-deep-linking) | After navigation initialization | Once after your navigation is ready to handle deep links |
293
- | [`linkrunner.trackEvent`](#track-event) | Throughout your app where events need to be tracked | When specific user actions or events occur |
294
- | [`linkrunner.capturePayment`](#capture-payment) | In your payment processing flow | When a user makes a payment |
295
- | [`linkrunner.removePayment`](#remove-payment) | In your payment cancellation/refund flow | When a payment needs to be removed |
296
-
297
- ### Facing issues during integration?
298
-
299
- Mail us on darshil@linkrunner.io
9
+ ## Documentation
10
+ For setup instructions, usage examples, and API reference, please visit:
11
+ [Linkrunner React Native SDK Documentation](https://docs.linkrunner.io/sdk/react-native/installation)
300
12
 
301
13
  ## License
14
+ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
302
15
 
303
- MIT
16
+ Copyright (c) 2025 Linkrunner Private Limited
@@ -0,0 +1,148 @@
1
+ // based on:
2
+ // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
3
+ // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
4
+
5
+ def DEFAULT_COMPILE_SDK_VERSION = 34
6
+ def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0'
7
+ def DEFAULT_MIN_SDK_VERSION = 24
8
+ def DEFAULT_TARGET_SDK_VERSION = 34
9
+
10
+ def safeExtGet(prop, fallback) {
11
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
12
+ }
13
+
14
+ buildscript {
15
+ ext {
16
+ buildToolsVersion = "34.0.0"
17
+ minSdkVersion = 24
18
+ compileSdkVersion = 34
19
+ targetSdkVersion = 34
20
+ kotlinVersion = "1.9.10" // Stable version compatible with most RN apps
21
+ }
22
+
23
+ // The Android Gradle plugin is only required when opening the android folder stand-alone.
24
+ // This avoids unnecessary downloads and potential conflicts when the library is included as a
25
+ // module dependency in an application project.
26
+ if (project == rootProject) {
27
+ repositories {
28
+ google()
29
+ mavenCentral()
30
+ }
31
+
32
+ dependencies {
33
+ classpath 'com.android.tools.build:gradle:8.3.2' // Stable LTS AGP version
34
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
35
+ }
36
+ }
37
+ }
38
+
39
+ apply plugin: 'com.android.library'
40
+ apply plugin: 'kotlin-android'
41
+
42
+ def getExtOrDefault(name) {
43
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNative_' + name]
44
+ }
45
+
46
+ def getExtOrIntegerDefault(name) {
47
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNative_' + name]).toInteger()
48
+ }
49
+
50
+ def supportsNamespace() {
51
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
52
+ def major = parsed[0].toInteger()
53
+ def minor = parsed[1].toInteger()
54
+
55
+ // Namespace support was added in 7.3.0
56
+ return (major == 7 && minor >= 3) || major >= 8
57
+ }
58
+
59
+ android {
60
+ if (supportsNamespace()) {
61
+ namespace "io.linkrunner.rnlinkrunner"
62
+
63
+ sourceSets {
64
+ main {
65
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
66
+ }
67
+ }
68
+ }
69
+
70
+ compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
71
+
72
+ defaultConfig {
73
+ minSdkVersion getExtOrIntegerDefault('minSdkVersion')
74
+ targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
75
+ versionCode 1
76
+ versionName "1.0"
77
+ }
78
+
79
+ buildTypes {
80
+ release {
81
+ minifyEnabled false
82
+ }
83
+ }
84
+
85
+ lintOptions {
86
+ disable 'GradleCompatible'
87
+ }
88
+
89
+ compileOptions {
90
+ sourceCompatibility JavaVersion.VERSION_11 // Keep Java 11 for RN compatibility
91
+ targetCompatibility JavaVersion.VERSION_11
92
+ }
93
+
94
+ kotlinOptions {
95
+ jvmTarget = '11' // Match Java version
96
+ }
97
+ }
98
+
99
+ repositories {
100
+ mavenLocal()
101
+ maven {
102
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
103
+ url "$rootDir/../node_modules/react-native/android"
104
+ }
105
+ maven {
106
+ // Android JSC is installed from npm
107
+ url "$rootDir/../node_modules/jsc-android/dist"
108
+ }
109
+ google()
110
+ mavenCentral()
111
+ jcenter()
112
+ maven { url 'https://www.jitpack.io' }
113
+ }
114
+
115
+ dependencies {
116
+ // React Native - use compileOnly to avoid version conflicts
117
+ implementation 'com.facebook.react:react-android:0.80.0'
118
+
119
+ // Linkrunner SDK
120
+ implementation "io.linkrunner:android-sdk:2.1.3"
121
+
122
+ // Kotlin standard libraries - use stable versions
123
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
124
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
125
+
126
+ // AndroidX dependencies - matching Android SDK exactly
127
+ implementation 'androidx.core:core-ktx:1.12.0'
128
+ implementation 'androidx.appcompat:appcompat:1.6.1'
129
+ implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
130
+ implementation 'androidx.lifecycle:lifecycle-process:2.7.0'
131
+
132
+ // Network dependencies - matching Android SDK versions
133
+ implementation 'com.squareup.retrofit2:retrofit:2.11.0'
134
+ implementation 'com.squareup.retrofit2:converter-gson:2.11.0'
135
+ implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
136
+
137
+ // Coroutines - matching Android SDK
138
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0'
139
+ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.8.0'
140
+
141
+ // Dependency Injection - matching Android SDK
142
+ implementation 'io.insert-koin:koin-android:3.5.3'
143
+
144
+ // Google Play Services - matching Android SDK exactly
145
+ implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
146
+ implementation 'com.google.android.gms:play-services-appset:16.0.2'
147
+ implementation 'com.android.installreferrer:installreferrer:2.2'
148
+ }
@@ -0,0 +1,52 @@
1
+ # Project-wide Gradle settings.
2
+ # IDE (e.g. Android Studio) users:
3
+ # Gradle settings configured through the IDE *will override*
4
+ # any settings specified in this file.
5
+
6
+ # For more details on how to configure your build environment visit
7
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
8
+
9
+ # Specifies the JVM arguments used for the daemon process.
10
+ # The setting is particularly useful for tweaking memory settings.
11
+ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
12
+
13
+ # When configured, Gradle will run in incubating parallel mode.
14
+ # This option should only be used with decoupled projects. More details, visit
15
+ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
16
+ # AndroidX package structure to make it clearer which packages are bundled with the
17
+ # Android operating system, and which are packaged with your app's APK
18
+ # https://developer.android.com/topic/libraries/support-library/androidx-rn
19
+ android.useAndroidX=true
20
+ # Automatically convert third-party libraries to use AndroidX
21
+ android.enableJetifier=true
22
+
23
+ # Gradle configuration settings to avoid deprecation warnings
24
+ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
25
+ org.gradle.parallel=true
26
+ org.gradle.caching=true
27
+ org.gradle.configureondemand=true
28
+
29
+ # This setting enables the new non-transitive R class generation
30
+ android.nonTransitiveRClass=true
31
+
32
+ # Kotlin code style for this project: "official" or "obsolete":
33
+ kotlin.code.style=official
34
+
35
+ # Use this property to specify which architecture you want to build.
36
+ # You can also override it from the CLI using
37
+ # ./gradlew <task> -PreactNativeArchitectures=x86_64
38
+ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
39
+
40
+ # Use this property to enable support to the new architecture.
41
+ # This will allow you to use TurboModules and the Fabric render in
42
+ # your application. You should enable this flag either if you want
43
+ # to write custom TurboModules/Fabric components OR use libraries that
44
+ # are providing them.
45
+ newArchEnabled=false
46
+
47
+ # Use this property to enable or disable the Hermes JS engine.
48
+ # If set to false, you will be using JSC instead.
49
+ hermesEnabled=true
50
+
51
+ # Enable the same timezone in daemon
52
+ org.gradle.jvmargs=-Duser.timezone=UTC
@@ -0,0 +1,6 @@
1
+ rootProject.name = 'rn-linkrunner'
2
+
3
+ apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
4
+ applyNativeModulesSettingsGradle(settings)
5
+
6
+ include ':app'
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="io.linkrunner.rnlinkrunner">
3
+ </manifest>