iOS SDK · Preview
Events and identity
Track custom events, screens and the ecommerce journey, and connect app activity to known customers on iOS.
Preview: planned API
The iOS SDK is in development and not published yet. This page describes the API we are building so you can plan your integration. Package names, signatures and defaults may still change before the first release.
Custom events and screens
Event names are lowercase snake_case, the same rule as the Web SDK. Properties accept strings, numbers, booleans, null and nested lists or maps.
RTN.track("filter_applied", properties: [
"filter": "color",
"value": "black",
])
RTN.screen("Product detail", properties: ["product_id": "sku_123"])Automatic screens
SwiftUI has no reliable automatic screen hook, so trackScreens only covers UIKit view controllers. In SwiftUI, add the .rtnScreen("Product detail") view modifier, which calls RTN.screen when the view appears.
Properties on every event
Registered properties are added to every following event until you remove them. Event properties win when both set the same key.
RTN.register(["app_theme": "dark"])
RTN.unregister("app_theme")Ecommerce journey
The ecommerce helpers send the same events as the Web SDK (product_viewed, product_added_to_cart, cart_viewed, checkout_started, order_completed and more), so web and app journeys appear side by side in reports and segments. The product fields and their rules are the same as in Ecommerce Events.
let product = RTNProduct(
productId: "sku_123",
variantId: "sku_123_black",
name: "Everyday Backpack",
brand: "Northwind",
category: "Bags",
price: 89.90,
currency: "USD"
)
RTN.productViewed(product)
RTN.productAddedToCart(product.with(quantity: 2), cartId: "cart_456")
RTN.checkoutStarted(cart)
RTN.orderCompleted(order)Identify customers
Call identify after sign-in or sign-up. Earlier anonymous events on this device are linked to the customer, and their web activity is merged when the same customer ID or email is used on your site.
// After sign-in or sign-up
RTN.identify(userId: "user_123", traits: [
"email": "ada@example.com",
"first_name": "Ada",
])
// Guest checkout: traits only
RTN.identify(traits: ["email": "guest@example.com"])
// At sign-out
RTN.reset()