iOS

Quick Start

Install and initialize the Stay22 iOS 3.x SDK.

Install the SDK

Use Swift Package Manager in Xcode: File > Add Package Dependencies, then enter:

https://github.com/Stay22/stay22-ios-sdk

Or declare the binary package in Package.swift:

dependencies: [
    .package(url: "https://github.com/Stay22/stay22-ios-sdk.git", from: "3.1.1")
]

Add the Stay22SDK product to your app target. SDK 3.1.1 requires iOS 15.0 and Swift 5.9 or later. SPM downloads a prebuilt framework. The from: rule permits later compatible releases; choose Exact Version in Xcode if you need this precise release.

The consent-required setup and persisted pre-initialization choice are available from SDK 1.4.0.

In Info.plist:

<key>Stay22RequiresConsent</key>
<true/>

Call SDK APIs on the main actor. Initialize during app launch, before handling a notification tap:

import Stay22SDK

@MainActor
func startStay22(userHasOptedIn: Bool) {
    Stay22.isEnabled = userHasOptedIn
    Stay22.initialize(aid: "your-partner-id")
}

When the user changes their choice, set Stay22.isEnabled again. Do this before submitting a trip.

Ask for notification permission

let granted = await Stay22.requestNotificationPermission()

Request permission at a point in your app where the user expects travel offers. Check it later with await Stay22.hasNotificationPermission().

Tell the SDK about the trip

import Foundation
import Stay22SDK

@MainActor
func submitTrip() -> NotificationResult {
    let now = Int64(Date().timeIntervalSince1970 * 1000)
    return Stay22.notifications.ensure(
        NotificationRequest(
            trip: TravelContext(address: "Paris, France"),
            timing: .after(delayMs: 30 * 60 * 1000),
            expiresAtMs: now + 12 * 60 * 60 * 1000,
            actionExpiresAtMs: now + 24 * 60 * 60 * 1000
        )
    )
}

The example chooses a 30-minute minimum wait and its own execution and tap deadlines; these are illustrative app choices, not SDK defaults. expiresAtMs limits scheduling, while actionExpiresAtMs limits opening after a tap. If you omit either deadline, the SDK needs a cached account validity policy or rejects the request with expiry_required.

Each request contains the whole trip. Omitted fields do not inherit earlier values. A submitted result acknowledges storage, not that the operating system has queued or shown the notification. Read receipt and timing behavior before deciding how to retry or replace it.

Platform setup notes

Add these schemes to Info.plist so the SDK can check booking-app availability:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>airbnb</string>
    <string>booking</string>
    <string>expda</string>
    <string>hotelsapp</string>
    <string>agoda</string>
</array>

Initialization installs the SDK as UNUserNotificationCenter.delegate and forwards to an existing delegate. If your app or another library takes that delegate afterward, forward Stay22 callbacks:

// In didReceive:
if Stay22.handleNotificationResponse(response) {
    completionHandler()
    return
}

// In willPresent:
if Stay22.isStay22Notification(notification) {
    let show = Stay22.handleWillPresentNotification(notification)
    completionHandler(show ? [.banner, .sound, .list] : [])
    return
}

Without forwarding, notification taps may not reach the SDK.

Check the integration

Follow the test notification instructions. Read what reaches Stay22 before completing your store privacy declarations.

On this page