Events, tags, attributes, and ping
Tags, attributes, ping, and triggerEvent on the MotiSig iOS SDK.
These APIs require an initialized SDK and, except where noted, a current user from setUser. If no user is set, tag/attribute/ping methods return without sending a request.
Tags
addTags(_ tags: [String], completion: ((Result<Void, Error>) -> Void)? = nil)—POSTto add tags for the current user.removeTags(_ tags: [String], completion: ((Result<Void, Error>) -> Void)? = nil)—DELETEto remove tags.
Attributes
setAttributes(_ attributes: [String: Any], completion: …)— JSON-encodable values are wrapped for the wire format.addOrUpdateAttributes(_ attributes: [String: Any], completion: …)— convenience alias aligned with other MotiSig SDKs.removeAttributes(keys: [String], completion: …)—DELETEselected keys.
Values must be encodable in practice for your payloads; unsupported types may fail at encode time and be logged.
ping()
Sends a heartbeat-style request for the current user (POST /users/{id}/ping). Useful for presence or liveness if your backend uses it.
triggerEvent(eventName:data:completion:)
Sends POST /events for the current user.
eventName: server-defined event name.data: optional[String: Any]JSON-serializable payload; omitted whennil.completion: optional; on success, called withResult.successcarrying the servermessagestring. On failure (including no user), called withResult.failure.
If there is no current user, the completion is invoked immediately with MotiSigError.userNotSet (and no request is enqueued).
If the SDK is not initialized or the instance is unavailable when the queued work runs, the completion may receive MotiSigError.notInitialized.
The completion runs on the Swift concurrency cooperative thread pool (not guaranteed to be the main queue). Dispatch to the main actor yourself if you update UI.
Related
- User and profile
MotiSigErrorin the SDK source for error cases