Skip to main content
SDKsiOS

Getting started

How the MotiSig iOS SDK fits into your app at runtime.

This guide describes how the MotiSig iOS SDK fits into your app at runtime. For install steps, see the iOS overview. For keys and URLs, see Configuration.

Overview

  1. Call MotiSig.initialize(...) once at launch (typically from application(_:didFinishLaunchingWithOptions:) or your SwiftUI @main app entry).
  2. When you know the signed-in user, call MotiSig.shared.setUser(id:). That registers the user with the MotiSig API and, when an APNs device token is available, upserts the push subscription for that user.
  3. Use MotiSig.shared for profile updates, tags, attributes, events, and notification listeners as needed.

Lifecycle

flowchart LR
  init[MotiSig.initialize]
  setUser[MotiSig.shared.setUser]
  api[Server mutations]
  token[APNs token registration]
  init --> setUser
  setUser --> api
  setUser --> token

After initialization, the SDK may request notification permission and register for remote notifications. Push wiring (including method swizzling) is installed as part of initialize; see Push notifications.

Ordered mutations

User-scoped HTTP mutations (setUser, tags, attributes, updateUser, ping, triggerEvent, push subscription upsert/patch/remove) run on an internal FIFO queue. Each queued item captures the user id (and token where applicable) at enqueue time, so work is not dropped if logout() clears storage before a request runs. See User and profile for logout details.

Next steps