API Reference

Complete API reference for the Smler React Native SDK. All classes, methods, parameters, return types, and TypeScript interfaces documented.


Complete reference for all classes, methods, and types exported by the @smler/deferred-link React Native SDK.


The main class for interacting with the SDK. All methods are static.

getInstallReferrerAndroid()

static async getInstallReferrerAndroid(): Promise<ReferrerInfo>

Reads the Google Play Install Referrer information. Android only.

  • Returns: ReferrerInfo — the raw referrer string and associated timestamps.

  • Throws: Error if called on a non-Android platform.

  • Throws: Error if the native module returns a service error (see Android docs for error codes).

parseReferrerParams(info)

static parseReferrerParams(info: ReferrerInfo): Record<string, string>

Parses the installReferrer string from a ReferrerInfo object as URL query parameters.

  • Parameters: info — a ReferrerInfo object from getInstallReferrerAndroid().

  • Returns: Key-value object of parsed parameters. Returns an empty object if the referrer is null or cannot be parsed.

getReferrerParam(info, key)

static getReferrerParam(info: ReferrerInfo, key: string): string

Extracts a single query parameter from the install referrer string.

  • Parameters:

    • info — a ReferrerInfo object.

    • key — the query parameter key to extract.

  • Returns: The parameter value, or an empty string if not found.

extractShortCodeAndDltHeader(info)

static extractShortCodeAndDltHeader(info: ReferrerInfo): PathParams

Extracts the shortCode and optional dltHeader from the referrer string's URL path.

  • Parameters: info — a ReferrerInfo object.

  • Returns: { shortCode: string, dltHeader: string | null }

    • If the referrer contains a URL with 2 path segments: first segment is dltHeader, second is shortCode.

    • If 1 segment: it is the shortCode, dltHeader is null.

    • If the referrer is empty or has no segments: shortCode is an empty string, dltHeader is null.

trackClick(info)

static async trackClick(info: ReferrerInfo): Promise<Record<string, unknown> | null>

Tracks a click via the Smler API using the clickId from the referrer. Automatically extracts clickId, shortCode, dltHeader, and domain from the referrer.

  • Parameters: info — a ReferrerInfo object.

  • Returns: The tracking API response, or null if no clickId is found in the referrer.

getInstallReferrerIos(options)

static async getInstallReferrerIos(options: {
  deepLinks: string[];
}): Promise<IosClipboardDeepLinkResult | null>

Reads the iOS clipboard and matches the text against the provided URL patterns. iOS only.

  • Parameters:

    • options.deepLinks — array of URL patterns to match against the clipboard. Supports scheme normalization, www. stripping, subdomain matching, wildcard host (*.example.com), wildcard path (example.com/*), and global wildcard (*).

  • Returns: IosClipboardDeepLinkResult if a match is found, null otherwise.

  • Throws: Error if called on a non-iOS platform.

resolveDeepLink(url, options?)

static async resolveDeepLink(
  url: string,
  options?: { triggerWebhook?: boolean }
): Promise<ResolvedDeepLinkData>

Resolves a Smler short link URL to get the original destination URL and full metadata. Works on both platforms.

  • Parameters:

    • url — the full short link URL to resolve.

    • options.triggerWebhook — when true, the Smler backend fires the configured webhook in the same request.

  • Returns: ResolvedDeepLinkData with the resolved metadata. Check the error field for failures.


HelperReferrer

Utility class with lower-level helper methods. All methods are static.

matchesDeepLinkPattern(clipboard, pattern)

static matchesDeepLinkPattern(clipboard: string, pattern: string): boolean

Checks if a clipboard string matches a deep link URL pattern.

  • Parameters:

    • clipboard — the clipboard text to check.

    • pattern — the URL pattern to match against.

  • Returns: true if the clipboard text matches the pattern.

fetchTrackingData(clickId, pathParams, domain?)

static async fetchTrackingData(
  clickId: string,
  pathParams: { shortCode?: string | null; dltHeader?: string | null },
  domain?: string | null
): Promise<TrackingResponse>

Sends click tracking data to the Smler API.

  • Parameters:

    • clickId — the click identifier.

    • pathParams.shortCode — the short URL code.

    • pathParams.dltHeader — optional DLT header.

    • domain — optional domain.

  • Returns: TrackingResponse. Check error field for failures.

  • API: POST https://smler.in/api/v2/track/{clickId}

getProbabilisticMatch(options)

static async getProbabilisticMatch(options: {
  domain: string;
  clickId?: string;
}): Promise<ProbabilisticMatchResult>

Performs probabilistic matching using device fingerprint data.

  • Parameters:

    • options.domain — the domain to match against (required).

    • options.clickId — optional click ID for more precise matching.

  • Returns: ProbabilisticMatchResult. Check matched and score fields.

  • API: POST https://smler.in/api/v2/track/probablistic

  • Note: Requires react-native-device-info for automatic device/OS detection. Falls back to "Unknown" if not installed.

resolveDeepLinkData(url, options?)

static async resolveDeepLinkData(
  url: string,
  options?: { triggerWebhook?: boolean }
): Promise<ResolvedDeepLinkData>

Resolves a short link URL to its full metadata. This is the underlying implementation of SmlerDeferredLink.resolveDeepLink().

  • Parameters: Same as resolveDeepLink().

  • Returns: ResolvedDeepLinkData.

  • API: GET https://smler.in/api/v1/short?short=<shortCode>&dltHeader=<dltHeader>&domain=<domain>

triggerWebhook(options)

static async triggerWebhook(options: {
  shortCode: string;
  domain: string;
  dltHeader?: string;
}): Promise<WebhookResponse>

Triggers a webhook notification for the given short link.

  • Parameters:

    • options.shortCode — the short URL code (required).

    • options.domain — the domain (required).

    • options.dltHeader — optional campaign header.

  • Returns: WebhookResponse. { success: true } on success.

  • API: POST https://smler.in/api/v1/webhook?shortCode=<code>&domain=<domain>&dltHeader=<header>

extractShortCodeAndDltHeader(url)

static extractShortCodeAndDltHeader(url: string): {
  shortCode: string;
  dltHeader: string | null;
}

Extracts the short code and optional DLT header from a URL's path segments.

  • Parameters: url — a full URL string.

  • Returns: { shortCode, dltHeader }. Returns empty shortCode and null dltHeader if the URL is invalid or has no path segments.

parseReferrerAsQueryParams(referrer)

static parseReferrerAsQueryParams(
  referrer: string | null
): Record<string, string>

Parses a referrer string as query parameters. Handles both full URLs and bare query strings.

  • Parameters: referrer — the referrer string, or null.

  • Returns: Key-value object. Returns an empty object if input is null or unparseable.


TypeScript Types

All types are exported from the package:

import type {
  ReferrerInfo,
  IosClipboardDeepLinkResult,
  ProbabilisticMatchResult,
  TrackingResponse,
  WebhookResponse,
  ResolvedDeepLinkData,
  PathParams,
} from '@smler/deferred-link';

ReferrerInfo

Field

Type

Description

installReferrer

string | null

Raw referrer string from Google Play

referrerClickTimestampSeconds

number

Client-side click timestamp (seconds)

installBeginTimestampSeconds

number

Client-side install-begin timestamp (seconds)

referrerClickTimestampServerSeconds

number

Server-side click timestamp (seconds)

installBeginTimestampServerSeconds

number

Server-side install-begin timestamp (seconds)

installVersion

string | null

App version at first install

googlePlayInstantParam

boolean

Whether instant experience was launched recently

IosClipboardDeepLinkResult

Field

Type

Description

fullDeepLink

string

Full deep link from clipboard

fullReferralDeepLinkPath

string

Alias for fullDeepLink

queryParameters

Record<string, string>

Parsed query parameters

pathParams

PathParams

Extracted shortCode and dltHeader

PathParams

Field

Type

Description

shortCode

string

Short URL code

dltHeader

string | null

Optional DLT header

ProbabilisticMatchResult

Field

Type

Description

matched

boolean

Whether a match was found

score

number | null

Confidence score (0.0–1.0)

matchedAttributes

unknown

Attributes that matched

clickDetails

unknown

Matched click details

shortUrl

Record<string, unknown> | null

Short URL metadata

fingerprint

unknown

Device fingerprint data

domain

string

Domain (if matched)

originalUrl

string

Original URL (if matched)

pathParams

{ shortCode, dltHeader, domain }

Path parameters (if matched)

error

string

Error code

message

string

Error message

ResolvedDeepLinkData

Field

Type

Description

shortCode

string

Short URL code

domain

string

Link domain

dltHeader

string

Campaign header

originalUrl

string

Original destination URL

error

string

Error code

message

string

Error message

TrackingResponse

Field

Type

Description

error

string

Error code

message

string

Error message

May contain additional fields from the API.

WebhookResponse

Field

Type

Description

success

boolean

Whether the webhook succeeded

error

string

Error code

message

string

Error message

Published with LeafPad