ChottuLink Capacitor SDK

ChottuLink is your all-in-one solution for creating, managing, and tracking dynamic links across platforms. Boost your marketing campaigns with smart deep linking and comprehensive analytics.
Features
- 🔗 Dynamic Link Creation - Create short, trackable links with custom parameters
- 📱 Deep Linking - Seamlessly route users to specific content in your app
- 📊 Analytics - Track link performance with UTM parameters
- 🎯 Platform-Specific Behavior - Control how links behave on iOS and Android
- 🔔 Event Listeners - Listen for deep link resolution events
- 🌐 Cross-Platform - Works on iOS, Android, and Web (with limitations)
Installation
npm install capacitor-chottulink-sdk
npx cap sync
Prerequisites
Before installing this plugin, ensure you have the following set up:
- Node.js: 16.x or higher
- Capacitor: 5.0.0 or higher
- iOS Deployment Target: 15.0 or higher
- Android SDK: API 21 (Android 5.0) or higher
- ChottuLink Account: A valid ChottuLink account with an API key
Getting Started
1. Initialize the SDK
Before using any ChottuLink features, you must initialize the SDK with your API key:
import { ChottuLinkIonicSDK } from 'capacitor-chottulink-sdk';
await ChottuLinkIonicSDK.initialize({
apiKey: 'your-api-key-here'
});
2. Create Dynamic Links
Create dynamic links with customizable parameters:
import { ChottuLinkIonicSDK, CLDynamicLinkBehaviour } from 'capacitor-chottulink-sdk';
const result = await ChottuLinkIonicSDK.createDynamicLink({
builder: {
destinationURL: 'https://example.com/product/123',
domain: 'your-domain.com',
linkName: 'product-link',
iosBehaviour: CLDynamicLinkBehaviour.app,
androidBehaviour: CLDynamicLinkBehaviour.app,
socialTitle: 'Check out this product!',
socialDescription: 'Amazing product description',
socialImageUrl: 'https://example.com/image.jpg',
utmSource: 'email',
utmMedium: 'campaign',
utmCampaign: 'summer-sale'
}
});
console.log('Short URL:', result.shortURL);
3. Handle Incoming Links:
ChottuLinkIonicSDK.addListener('onDeepLinkResolved', (data) => {
console.log('Deep link resolved:', data.url);
console.log('Metadata:', data.metadata);
});
ChottuLinkIonicSDK.addListener('onDeepLinkFailed', (data) => {
console.error('Deep link failed:', data.error);
console.log('Original URL:', data.originalURL);
});
4. (Optional) Get AppLink Data from the Deeplink URL directly
const resolved = await ChottuLinkIonicSDK.getAppLinkDataFromUrl({
shortURL: 'https://your-domain.com/abc123'
});
if (resolved) {
console.log('Original link:', resolved.link);
console.log('Short link:', resolved.shortLink);
console.log('Short link Raw:', resolved.shortLinkRaw);
console.log('isDeferred:', resolved.isDeferred);
}
Web
⚠️ Note: The plugin methods are not fully implemented on web. They will throw unimplemented errors. This plugin is primarily designed for native mobile platforms.
API
initialize(...)
initialize(options: { apiKey: string; }) => Promise<void>
options | { apiKey: string; } |
createDynamicLink(...)
createDynamicLink(options: { builder: CLDynamicLinkBuilder; }) => Promise<{ shortURL: string | null; }>
Returns: Promise<{ shortURL: string | null; }>
getAppLinkDataFromUrl(...)
getAppLinkDataFromUrl(options: { shortURL: string; }) => Promise<CLResolvedLink | null>
options | { shortURL: string; } |
Returns: Promise<CLResolvedLink | null>
addListener('onDeepLinkResolved', ...)
addListener(eventName: 'onDeepLinkResolved', listenerFunc: (data: { url: string; metadata?: Record<string, any>; }) => void) => Promise<PluginListenerHandle>
eventName | 'onDeepLinkResolved' |
listenerFunc | (data: { url: string; metadata?: Record<string, any>; }) => void |
Returns: Promise<PluginListenerHandle>
addListener('onDeepLinkFailed', ...)
addListener(eventName: 'onDeepLinkFailed', listenerFunc: (data: { error: string; originalURL?: string; }) => void) => Promise<PluginListenerHandle>
eventName | 'onDeepLinkFailed' |
listenerFunc | (data: { error: string; originalURL?: string; }) => void |
Returns: Promise<PluginListenerHandle>
Interfaces
CLDynamicLinkBuilder
destinationURL | string |
domain | string |
linkName | string |
androidBehaviour | CLDynamicLinkBehaviour |
iosBehaviour | CLDynamicLinkBehaviour |
selectedPath | string |
socialTitle | string |
socialDescription | string |
socialImageUrl | string |
utmSource | string |
utmMedium | string |
utmCampaign | string |
utmContent | string |
utmTerm | string |
CLResolvedLink
isDeferred | boolean | null |
link | string | null |
shortLink | string | null |
shortLinkRaw | string | null |
PluginListenerHandle
remove | () => Promise<void> |
Type Aliases
Record
Construct a type with a set of properties K of type T
{
[P in K]: T;
}
Enums
CLDynamicLinkBehaviour
Complete Example
Here's a complete example of how to use the plugin in your Capacitor app:
import { ChottuLinkIonicSDK, CLDynamicLinkBehaviour } from 'capacitor-chottulink-sdk';
async function initChottuLink() {
try {
await ChottuLinkIonicSDK.initialize({
apiKey: 'your-api-key-here'
});
console.log('ChottuLink SDK initialized');
} catch (error) {
console.error('Failed to initialize ChottuLink:', error);
}
}
function setupDeepLinkListeners() {
ChottuLinkIonicSDK.addListener('onDeepLinkResolved', (data) => {
console.log('Deep link resolved:', data.url);
});
ChottuLinkIonicSDK.addListener('onDeepLinkFailed', (data) => {
console.error('Deep link failed:', data.error);
});
}
async function shareProduct(productId: string) {
try {
const result = await ChottuLinkIonicSDK.createDynamicLink({
builder: {
destinationURL: `https://yourapp.com/products/${productId}`,
domain: 'your-domain.com',
linkName: `product-${productId}`,
iosBehaviour: CLDynamicLinkBehaviour.app,
androidBehaviour: CLDynamicLinkBehaviour.app,
socialTitle: 'Check out this amazing product!',
socialDescription: 'You won\'t believe what this product can do.',
socialImageUrl: `https://yourapp.com/images/products/${productId}.jpg`,
utmSource: 'app',
utmMedium: 'share',
utmCampaign: 'product-sharing'
}
});
if (result.shortURL) {
await Share.share({ url: result.shortURL });
}
} catch (error) {
console.error('Failed to create dynamic link:', error);
}
}
initChottuLink();
setupDeepLinkListeners();
Troubleshoot & Test Deep links
For more detailed troubleshooting steps and testing procedures, visit: https://docs.chottulink.com/troubleshooting