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
- Call
MotiSig.initialize(...)once at launch (typically fromapplication(_:didFinishLaunchingWithOptions:)or your SwiftUI@mainapp entry). - 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. - Use
MotiSig.sharedfor 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 --> tokenAfter 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
- Configuration — keys, base URL, logging
- User and profile —
setUser,updateUser,logout - Events, tags, attributes — events, tags, attributes, ping
- Push notifications — listeners and payloads