Skip to content

tolinku/ios-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TolinkuSDK

Swift Package Manager Platform License: MIT

The official Tolinku SDK for iOS. Add deep linking, analytics, referral tracking, deferred deep links, and in-app messages to your iOS app. Supports Universal Links out of the box.

What is Tolinku?

Tolinku is a deep linking platform for mobile and web apps. It handles Universal Links (iOS), App Links (Android), deferred deep linking, referral programs, analytics, and smart banners. Tolinku provides a complete toolkit for user acquisition, attribution, and engagement across platforms.

Get your API key at tolinku.com and check out the documentation to get started.

Installation

Add TolinkuSDK using Swift Package Manager:

  1. In Xcode, go to File > Add Package Dependencies...
  2. Enter the repository URL: https://github.com/tolinku/ios-sdk
  3. Select your version rule and add the package to your target

Requirements: iOS 15+

Quick Start

import TolinkuSDK

// Configure the SDK (typically in AppDelegate or App init)
let tolinku = try Tolinku.configure(apiKey: "tolk_pub_your_api_key")

// Identify a user
tolinku.setUserId("user_123")

// Track a custom event
await tolinku.track("purchase", properties: ["plan": .string("growth")])

Features

Analytics

Track custom events with automatic batching. Events are queued and sent in batches of 10, or every 5 seconds. Events are also flushed when the app moves to the background.

await tolinku.track("signup_completed", properties: [
    "source": .string("landing_page"),
    "trial": .bool(true),
])

// Flush queued events immediately
await tolinku.flush()

Referrals

Create and manage referral programs with leaderboards and reward tracking.

let referrals = tolinku.referrals

// Create a referral
let result = try await referrals.create(userId: "user_123", userName: "Alice")
let code = result.referralCode

// Look up a referral
let details = try await referrals.get(code: code)

// Complete a referral
let completion = try await referrals.complete(
    code: code,
    referredUserId: "user_456",
    referredUserName: "Bob"
)

// Update milestone
let milestone = try await referrals.milestone(code: code, milestone: "first_purchase")

// Claim reward
let reward = try await referrals.claimReward(code: code)

// Fetch leaderboard
let entries = try await referrals.leaderboard(limit: 10)

Ecommerce

Track purchases, cart activity, and product events with built-in revenue analytics. Available on paid plans.

tolinku.setUserId("user_123")

// Track a product view
await tolinku.ecommerce.viewItem(
    items: [TolinkuItem(itemId: "sku_1", itemName: "T-Shirt", price: 24.99)]
)

// Track a purchase
await tolinku.ecommerce.purchase(
    transactionId: "order_456",
    revenue: 49.99,
    currency: "USD",
    items: [TolinkuItem(itemId: "sku_1", itemName: "T-Shirt", price: 24.99, quantity: 2)]
)

// Flush ecommerce events
await tolinku.ecommerce.flush()

The SDK supports 13 event types covering the full shopping journey. Money values use Swift Decimal for precision. Cart IDs are managed automatically via UserDefaults and cleared after purchase. Events auto-flush when the app enters the background.

Deferred Deep Links

Recover deep link context for users who installed your app after clicking a link. Deferred deep linking lets you route users to specific content even when the app was not installed at the time of the click.

let deferred = tolinku.deferred

// Claim by referrer token
if let link = try await deferred.claimByToken("abc123") {
    print(link.deepLinkPath) // e.g. "/merchant/xyz"
}

// Claim by device signal matching (auto-collects timezone, language, screen size)
if let link = try await deferred.claimBySignals(appspaceId: "your_appspace_id") {
    navigateTo(link.deepLinkPath)
}

Universal Link Handling

Parse incoming Universal Links with a simple utility method (no SDK configuration required).

func application(
    _ application: UIApplication,
    continue userActivity: NSUserActivity,
    restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
    guard let url = userActivity.webpageURL,
          let result = Tolinku.handleUniversalLink(url) else {
        return false
    }
    // result.path - the deep link path
    // result.queryItems - any query parameters
    navigateTo(result.path, queryItems: result.queryItems)
    return true
}

In-App Messages

Display server-configured messages as modal overlays using TolinkuMessagePresenter. Create and manage messages from the Tolinku dashboard without shipping app updates.

// Show the highest-priority message matching a trigger
await tolinku.messages.show(trigger: "milestone", from: viewController)

// With action and dismiss callbacks
await tolinku.messages.show(
    trigger: "milestone",
    from: viewController,
    onAction: { action in
        print("Button tapped: \(action)")
    },
    onDismiss: {
        print("Message dismissed")
    }
)

You can also fetch and present messages manually:

let messages = try await tolinku.messages.fetch(trigger: "milestone")
if let message = messages.first {
    TolinkuMessagePresenter.show(message: message, from: viewController)
}

Configuration Options

// Full configuration
let tolinku = try Tolinku.configure(
    apiKey: "tolk_pub_your_api_key",    // Required. Your Tolinku publishable API key.
    baseURL: "https://api.tolinku.com" // Optional. API base URL.
)

// Set user identity at any time
tolinku.setUserId("user_123")

// Shut down the SDK when done
await Tolinku.shutdown()

API Reference

Tolinku

Method Description
configure(apiKey:baseURL:) Initialize the SDK (static)
shared Access the configured instance (static, optional)
requireShared() Access the configured instance or throw (static)
setUserId(_:) Set or clear the current user ID
track(_:properties:) Track a custom event
flush() Flush queued analytics events
handleUniversalLink(_:) Parse a Universal Link URL (static)
shutdown() Release all resources (static)

tolinku.referrals

Method Description
create(userId:metadata:userName:) Create a new referral
get(code:) Get referral details by code
complete(code:referredUserId:milestone:referredUserName:) Mark a referral as converted
milestone(code:milestone:) Update a referral milestone
claimReward(code:) Claim a referral reward
leaderboard(limit:) Fetch the referral leaderboard

tolinku.ecommerce

Method Description
viewItem(items:) Track a product view
addToCart(items:) Track item added to cart
removeFromCart(items:) Track item removed from cart
addToWishlist(items:) Track item added to wishlist
viewCart() Track cart view
addPaymentInfo() Track payment info entered
beginCheckout() Track checkout started
purchase(transactionId:revenue:currency:items:) Track a purchase
refund(transactionId:revenue:) Track a refund
search(searchTerm:) Track a product search
share(itemId:) Track a product share
rate(itemId:rating:maxRating:) Track a product rating
spendCredits(revenue:currency:) Track loyalty credits spent
flush() Send all queued ecommerce events

tolinku.deferred

Method Description
claimByToken(_:) Claim a deferred link by token
claimBySignals(appspaceId:) Claim a deferred link by device signals

tolinku.messages

Method Description
fetch(trigger:) Fetch messages with optional trigger filter
renderToken(messageId:) Get a render token for a message
show(trigger:from:onAction:onDismiss:) Show the highest-priority message

Documentation

Full documentation is available at tolinku.com/docs.

Community

License

MIT

About

The official Tolinku SDK for iOS. Add deep linking, analytics, referral tracking, deferred deep links, and in-app messages to your Swift app.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages