cordova-linkrunner
v1.1.0
Published
Linkrunner SDK plugin for Apache Cordova
Maintainers
Readme
Linkrunner Cordova SDK
A Cordova plugin for integrating Linkrunner attribution, deeplinks, and analytics into your Apache Cordova applications.
Requirements
- Apache Cordova 10.0.0+
- iOS 15.0+ / Android 5.0 (API level 21)+
- Kotlin support for Android
Installation
cordova plugin add cordova-linkrunnerConfiguration
Android - Enable Kotlin
Add the following to your config.xml:
<preference name="GradlePluginKotlinEnabled" value="true" />
<preference name="GradlePluginKotlinCodeStyle" value="official" />iOS - Info.plist Configuration
The plugin automatically configures the following in your Info.plist:
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
<key>NSAdvertisingAttributionReportEndpoint</key>
<string>https://linkrunner-skan.com</string>
<key>AttributionCopyEndpoint</key>
<string>https://linkrunner-skan.com</string>Usage
Initialization
Initialize the SDK when your app starts:
document.addEventListener('deviceready', function() {
linkrunner.init({
token: 'YOUR_PROJECT_TOKEN',
secretKey: 'YOUR_SECRET_KEY', // Optional: for request signing
keyId: 'YOUR_KEY_ID', // Optional: for request signing
disableIdfa: false, // Optional: disable IDFA on iOS
debug: true // Optional: enable debug logging
}).then(function() {
console.log('Linkrunner initialized');
}).catch(function(error) {
console.error('Linkrunner init failed:', error);
});
}, false);User Registration
Call signup after user completes onboarding:
linkrunner.signup({
user_data: {
id: '123', // Required
name: 'John Doe', // Optional
phone: '9876543210', // Optional
email: '[email protected]', // Optional
user_created_at: '2024-01-01T00:00:00Z', // Optional
is_first_time_user: true, // Optional
mixpanel_distinct_id: 'mixpanel_id', // Optional
amplitude_device_id: 'amplitude_id', // Optional
posthog_distinct_id: 'posthog_id' // Optional
},
data: {} // Optional: additional data
}).then(function() {
console.log('Signup successful');
}).catch(function(error) {
console.error('Signup failed:', error);
});Set User Data
Call setUserData each time the app opens with a logged-in user:
linkrunner.setUserData({
id: '123', // Required
name: 'John Doe', // Optional
email: '[email protected]' // Optional
}).then(function() {
console.log('User data set');
});Track Events
linkrunner.trackEvent('purchase_completed', {
product_id: '12345',
category: 'electronics',
amount: 99.99
}).then(function() {
console.log('Event tracked');
});Capture Payment
linkrunner.capturePayment({
userId: 'user123',
amount: 100,
paymentId: 'payment456', // Optional
type: 'FIRST_PAYMENT', // Optional
status: 'PAYMENT_COMPLETED' // Optional
}).then(function() {
console.log('Payment captured');
});Get Attribution Data
linkrunner.getAttributionData().then(function(result) {
console.log('Attribution data:', result.data);
// result.data.deeplink
// result.data.campaignData
});Handle Deeplinks
To enable remarketing and reattribution, capture deeplinks and pass them to Linkrunner.
Step 1: Install Universal Links Plugin
cordova plugin add cordova-universal-links-plugin --saveStep 2: Configure Universal Links
Add to your config.xml:
<universal-links>
<host name="yourdomain.com" scheme="https">
<path url="/*" />
</host>
</universal-links>Step 3: Handle Deeplinks
document.addEventListener('deviceready', function() {
// Initialize Linkrunner first
linkrunner.init({ token: 'YOUR_TOKEN' });
// Subscribe to deeplink events
universalLinks.subscribe(null, function(eventData) {
console.log('Deeplink received:', eventData.url);
// Pass to Linkrunner for attribution
linkrunner.handleDeeplink(eventData.url).then(function(result) {
console.log('Deeplink handled:', result);
// result.data.is_linkrunner - whether it's a Linkrunner link
// result.data.deeplink - the resolved deeplink URL
// result.data.processing - whether still processing (optional)
});
});
}, false);Alternative: Custom URL Scheme
For custom URL schemes (e.g., myapp://), use the handleOpenURL function:
window.handleOpenURL = function(url) {
console.log('Custom URL received:', url);
linkrunner.handleDeeplink(url).then(function(result) {
console.log('Deeplink handled:', result);
});
};Payment Types
FIRST_PAYMENT- First payment by userWALLET_TOPUP- Adding funds to walletFUNDS_WITHDRAWAL- Withdrawing fundsSUBSCRIPTION_CREATED- New subscriptionSUBSCRIPTION_RENEWED- Subscription renewalONE_TIME- One-time paymentRECURRING- Recurring paymentDEFAULT- Default type
Payment Status
PAYMENT_INITIATED- Payment initiatedPAYMENT_COMPLETED- Payment completed (default)PAYMENT_FAILED- Payment failedPAYMENT_CANCELLED- Payment cancelled
Additional Features
Set Integration Data
linkrunner.setAdditionalData({
clevertapId: 'YOUR_CLEVERTAP_ID'
});Enable PII Hashing
linkrunner.enablePIIHashing(true);Set Push Token
linkrunner.setPushToken('YOUR_PUSH_TOKEN');Function Placement Guide
| Function | Where to Place | When to Call |
|----------|---------------|--------------|
| init | App initialization | Once when app starts |
| signup | Onboarding flow | Once after user completes onboarding |
| setUserData | Authentication logic | Every time app opens with logged-in user |
| trackEvent | Throughout app | When specific user actions occur |
| capturePayment | Payment processing | When user makes a payment |
| getAttributionData | Attribution flow | When attribution data is needed |
| handleDeeplink | Deeplink entry points | When app is opened via deeplink |
Documentation
For complete documentation, visit: https://docs.linkrunner.io/sdk/cordova
Support
For issues or questions, contact: [email protected]
License
MIT License - Copyright (c) 2026 Linkrunner Private Limited
