Last updated:
0 purchases
linkrunner
linkrunner #
Flutter Package for linkrunner.io
Installation #
Step 1: Installing linkrunner #
Installing through cmdline
run the following:
flutter pub add linkrunner
copied to clipboard
OR
Manually adding dependencies
Add linkrunner to your pubspec.yaml under dependencies:
dependencies:
linkrunner: ^0.7.6
copied to clipboard
Then run:
flutter pub get
copied to clipboard
to install your new dependency.
Step 2: Android updates #
Add the following in app/build.gradle file
dependencies {
...
implementation("com.android.installreferrer:installreferrer:2.2")
}
copied to clipboard
Usage #
Initialisation #
You will need your project token to initialise the package.
Place it in the main function:
import 'package:linkrunner/main.dart';
// Initialize the package
final linkrunner = LinkRunner();
void main() async {
// Call the .ensureInitialized method before calling the .init method
WidgetsFlutterBinding.ensureInitialized();
final init = await lr.init("YOUR_PROJECT_TOKEN");
runApp(MyApp());
}
copied to clipboard
Response type for linkrunner.init
{
ip_location_data: {
ip: string;
city: string;
countryLong: string;
countryShort: string;
latitude: number;
longitude: number;
region: string;
timeZone: string;
zipCode: string;
};
deeplink: string;
root_domain: boolean;
}
copied to clipboard
Trigger #
Call this function once your onboarding is completed and the main stack is loaded
import 'package:linkrunner/main.dart';
void trigger() async {
final trigger = await linkrunner.trigger(
userData: LRUserData(
id: '1',
name: 'John Doe', // optional
phone: '9583849238', // optional
email: '[email protected]', //optional
),
data: {}, // Any other data you might need
config: TriggerConfig(
triggerDeeplink: true // true by default
)
);
}
copied to clipboard
By setting config > triggerDeeplink as true the deeplink won't be trigged (Only set to false if you are handling the redirection by yourself)
You can pass any additional user related data in the data attribute
Response type for linkrunner.trigger
{
ip_location_data: {
ip: string;
city: string;
countryLong: string;
countryShort: string;
latitude: number;
longitude: number;
region: string;
timeZone: string;
zipCode: string;
};
deeplink: string;
root_domain: boolean;
trigger: boolean; // Deeplink won't be triggered if false
}
copied to clipboard
Note: Value of trigger will be only true for the first time the function is triggered by the user in order to prevent unnecessary redirects
Capture revenue #
Call this function after a payment is confirmed
import 'package:linkrunner/models/lr_capture_payment.dart';
void capturePayment() async {
await linkrunner.capturePayment(
capturePayment: LRCapturePayment(
userId: '666',
amount: 24168, // Send amount in one currency only
paymentId: 'AJKHAS' // optional but recommended
),
);
}
copied to clipboard
NOTE: If you accept payments in multiple currencies convert them to one currency before calling the above function
Remove captured payment revenue #
Call this function after a payment is cancelled or refunded
import 'package:linkrunner/models/lr_remove_payment.dart';
void removeCapturedPayment() async {
await linkrunner.removePayment(
removePayment: LRRemovePayment(
userId: '666',
paymentId: 'AJKHAS' // Ethier paymentId or userId is required!
),
);
}
copied to clipboard
NOTE: userId or paymentId is required in order to remove a payment entry, if you use userId all the payments attributed to that user will be removed
Facing issues during integration? #
Email us at [email protected]
License #
MIT
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.