Swift User Client
Setup & Configuration
Supported Language Versions
This SDK is compatible with the following versions:
- iOS 13.0+, macOS 15.0+, tvOS 13.0+, watchOS 6.0+, visionOS 1.0+
- Swift 6.0+
- Xcode 16+
Installation
This package depends on the Swift OpenAPI Runtime which is only available via Swift Package Manager.
Swift Package Manager
To install MagicBell using Swift Package Manager, add the dependency as follows to your project:
dependencies: [
.package(url: "https://github.com/magicbell/magicbell-swift-user-client", .upToNextMajor(from: "0.4.0"))
]
Authentication
Access Token Authentication
The MagicBell API uses an Access Token for authentication.
This token must be provided to authenticate your requests to the API.
Setting the Access Token
When you initialize the SDK, you can set the access token via the AuthenticationMiddleware
:
let authMiddleware = AuthenticationMiddleware(jwtToken: token)
let client = MagicBellUserClient.Client(
serverURL: try Servers.Server1.url(),
configuration: .init(dateTranscoder: .iso8601WithFractionalSeconds),
transport: URLSessionTransport(),
middlewares: [authMiddleware])
If you need to set or update the access token after initializing the SDK you can create a new Client instance.
Sample Usage
Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
import Foundation
import MagicBellUserClient
import OpenAPIURLSession
let token = "YOUR_ACCESS_TOKEN"
@main
struct MainApp {
static func main() async throws {
let client = MagicBellUserClient.Client(
serverURL: try Servers.Server1.url(),
configuration: .init(dateTranscoder: .iso8601WithFractionalSeconds),
transport: URLSessionTransport(),
middlewares: [AuthenticationMiddleware(jwtToken: token)])
let response = try await client.get_mobile_push_apns_tokens(.init())
switch response {
case .ok(let okResponse):
let json = try okResponse.body.json
let tokens = json.data
print("Found \(tokens?.count ?? 0) tokens")
tokens?.forEach({ token in
print("- token: \(token.data.device_token)")
})
case .undocumented(let statusCode, _):
print("Undocumented status code: \(statusCode)")
}
}
}
License
This SDK is licensed under the MIT License.
See the LICENSE file for more details.
Reference Documentation
Protocols
Structs
- Client
- Components.Schemas.APNSToken
- Components.Schemas.APNSTokenResponse
- Components.Schemas.ArrayOfAPNSTokenResponses
- Components.Schemas.ArrayOfExpoTokenResponses
- Components.Schemas.ArrayOfFCMTokenResponses
- Components.Schemas.ArrayOfSlackTokenResponses
- Components.Schemas.ArrayOfTeamsTokenResponses
- Components.Schemas.ArrayOfWebPushTokenResponses
- Components.Schemas.DiscardResult
- Components.Schemas.ExpoToken
- Components.Schemas.ExpoTokenResponse
- Components.Schemas.FCMToken
- Components.Schemas.FCMTokenResponse
- Components.Schemas.InboxConfig
- Components.Schemas.InboxConfig.imagesPayload
- Components.Schemas.InboxConfig.themePayload
- Components.Schemas.InboxConfig.themePayload.bannerPayload
- Components.Schemas.InboxConfig.themePayload.dialogPayload
- Components.Schemas.InboxConfig.themePayload.footerPayload
- Components.Schemas.InboxConfig.themePayload.headerPayload
- Components.Schemas.InboxConfig.themePayload.iconPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload._defaultPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload._defaultPayload.hoverPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload._defaultPayload.statePayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unreadPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unreadPayload.hoverPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unreadPayload.statePayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unseenPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unseenPayload.hoverPayload
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unseenPayload.statePayload
- Components.Schemas.InboxConfig.themePayload.unseenBadgePayload
- Components.Schemas.Links
- Components.Schemas.SlackFinishInstallResponse
- Components.Schemas.SlackInstallation
- Components.Schemas.SlackInstallation.authed_userPayload
- Components.Schemas.SlackInstallation.enterprisePayload
- Components.Schemas.SlackInstallation.incoming_webhookPayload
- Components.Schemas.SlackInstallation.teamPayload
- Components.Schemas.SlackStartInstall
- Components.Schemas.SlackStartInstallResponseContent
- Components.Schemas.SlackToken
- Components.Schemas.SlackToken.oauthPayload
- Components.Schemas.SlackToken.webhookPayload
- Components.Schemas.SlackTokenResponse
- Components.Schemas.SlackTokenResponse.oauthPayload
- Components.Schemas.SlackTokenResponse.webhookPayload
- Components.Schemas.TeamsToken
- Components.Schemas.TeamsToken.webhookPayload
- Components.Schemas.TeamsTokenResponse
- Components.Schemas.TeamsTokenResponse.webhookPayload
- Components.Schemas.TemplatesInstallation
- Components.Schemas.WebPushStartInstallationResponse
- Components.Schemas.WebPushToken
- Components.Schemas.WebPushToken.keysPayload
- Components.Schemas.WebPushTokenResponse
- Components.Schemas.WebPushTokenResponse.keysPayload
- Operations.discard_mobile_push_apns_token.Input
- Operations.discard_mobile_push_apns_token.Input.Headers
- Operations.discard_mobile_push_apns_token.Input.Path
- Operations.discard_mobile_push_apns_token.Output.Ok
- Operations.discard_mobile_push_expo_token.Input
- Operations.discard_mobile_push_expo_token.Input.Headers
- Operations.discard_mobile_push_expo_token.Input.Path
- Operations.discard_mobile_push_expo_token.Output.Ok
- Operations.discard_mobile_push_fcm_token.Input
- Operations.discard_mobile_push_fcm_token.Input.Headers
- Operations.discard_mobile_push_fcm_token.Input.Path
- Operations.discard_mobile_push_fcm_token.Output.Ok
- Operations.discard_slack_token.Input
- Operations.discard_slack_token.Input.Headers
- Operations.discard_slack_token.Input.Path
- Operations.discard_slack_token.Output.Ok
- Operations.discard_teams_token.Input
- Operations.discard_teams_token.Input.Headers
- Operations.discard_teams_token.Input.Path
- Operations.discard_teams_token.Output.Ok
- Operations.discard_web_push_token.Input
- Operations.discard_web_push_token.Input.Headers
- Operations.discard_web_push_token.Input.Path
- Operations.discard_web_push_token.Output.Ok
- Operations.finish_slack_installation.Input
- Operations.finish_slack_installation.Input.Headers
- Operations.finish_slack_installation.Output.Created
- Operations.get_mobile_push_apns_token.Input
- Operations.get_mobile_push_apns_token.Input.Headers
- Operations.get_mobile_push_apns_token.Input.Path
- Operations.get_mobile_push_apns_token.Output.Ok
- Operations.get_mobile_push_apns_tokens.Input
- Operations.get_mobile_push_apns_tokens.Input.Headers
- Operations.get_mobile_push_apns_tokens.Input.Query
- Operations.get_mobile_push_apns_tokens.Output.Ok
- Operations.get_mobile_push_expo_token.Input
- Operations.get_mobile_push_expo_token.Input.Headers
- Operations.get_mobile_push_expo_token.Input.Path
- Operations.get_mobile_push_expo_token.Output.Ok
- Operations.get_mobile_push_expo_tokens.Input
- Operations.get_mobile_push_expo_tokens.Input.Headers
- Operations.get_mobile_push_expo_tokens.Input.Query
- Operations.get_mobile_push_expo_tokens.Output.Ok
- Operations.get_mobile_push_fcm_token.Input
- Operations.get_mobile_push_fcm_token.Input.Headers
- Operations.get_mobile_push_fcm_token.Input.Path
- Operations.get_mobile_push_fcm_token.Output.Ok
- Operations.get_mobile_push_fcm_tokens.Input
- Operations.get_mobile_push_fcm_tokens.Input.Headers
- Operations.get_mobile_push_fcm_tokens.Input.Query
- Operations.get_mobile_push_fcm_tokens.Output.Ok
- Operations.get_slack_token.Input
- Operations.get_slack_token.Input.Headers
- Operations.get_slack_token.Input.Path
- Operations.get_slack_token.Output.Ok
- Operations.get_slack_tokens.Input
- Operations.get_slack_tokens.Input.Headers
- Operations.get_slack_tokens.Input.Query
- Operations.get_slack_tokens.Output.Ok
- Operations.get_teams_token.Input
- Operations.get_teams_token.Input.Headers
- Operations.get_teams_token.Input.Path
- Operations.get_teams_token.Output.Ok
- Operations.get_teams_tokens.Input
- Operations.get_teams_tokens.Input.Headers
- Operations.get_teams_tokens.Input.Query
- Operations.get_teams_tokens.Output.Ok
- Operations.get_web_push_token.Input
- Operations.get_web_push_token.Input.Headers
- Operations.get_web_push_token.Input.Path
- Operations.get_web_push_token.Output.Ok
- Operations.get_web_push_tokens.Input
- Operations.get_web_push_tokens.Input.Headers
- Operations.get_web_push_tokens.Input.Query
- Operations.get_web_push_tokens.Output.Ok
- Operations.save_inbox_installation.Input
- Operations.save_inbox_installation.Input.Headers
- Operations.save_inbox_installation.Output.Created
- Operations.save_mobile_push_apns_token.Input
- Operations.save_mobile_push_apns_token.Input.Headers
- Operations.save_mobile_push_apns_token.Output.Created
- Operations.save_mobile_push_expo_token.Input
- Operations.save_mobile_push_expo_token.Input.Headers
- Operations.save_mobile_push_expo_token.Output.Created
- Operations.save_mobile_push_fcm_token.Input
- Operations.save_mobile_push_fcm_token.Input.Headers
- Operations.save_mobile_push_fcm_token.Output.Created
- Operations.save_slack_installation.Input
- Operations.save_slack_installation.Input.Headers
- Operations.save_slack_installation.Output.Created
- Operations.save_slack_token.Input
- Operations.save_slack_token.Input.Headers
- Operations.save_slack_token.Output.Created
- Operations.save_teams_token.Input
- Operations.save_teams_token.Input.Headers
- Operations.save_teams_token.Output.Created
- Operations.save_templates_installation.Input
- Operations.save_templates_installation.Input.Headers
- Operations.save_templates_installation.Output.Created
- Operations.save_web_push_installation.Input
- Operations.save_web_push_installation.Input.Headers
- Operations.save_web_push_installation.Output.Created
- Operations.save_web_push_token.Input
- Operations.save_web_push_token.Input.Headers
- Operations.save_web_push_token.Output.Created
- Operations.start_inbox_installation.Input
- Operations.start_inbox_installation.Input.Headers
- Operations.start_inbox_installation.Output.Created
- Operations.start_slack_installation.Input
- Operations.start_slack_installation.Input.Headers
- Operations.start_slack_installation.Output.Created
- Operations.start_web_push_installation.Input
- Operations.start_web_push_installation.Input.Headers
- Operations.start_web_push_installation.Output.Created
Enums
- Components
- Components.Headers
- Components.Parameters
- Components.RequestBodies
- Components.Responses
- Components.Schemas
- Components.Schemas.APNSToken.CodingKeys
- Components.Schemas.APNSToken.installation_idPayload
- Components.Schemas.APNSTokenResponse.CodingKeys
- Components.Schemas.APNSTokenResponse.installation_idPayload
- Components.Schemas.ArrayOfAPNSTokenResponses.CodingKeys
- Components.Schemas.ArrayOfExpoTokenResponses.CodingKeys
- Components.Schemas.ArrayOfFCMTokenResponses.CodingKeys
- Components.Schemas.ArrayOfSlackTokenResponses.CodingKeys
- Components.Schemas.ArrayOfTeamsTokenResponses.CodingKeys
- Components.Schemas.ArrayOfWebPushTokenResponses.CodingKeys
- Components.Schemas.DiscardResult.CodingKeys
- Components.Schemas.ExpoToken.CodingKeys
- Components.Schemas.ExpoTokenResponse.CodingKeys
- Components.Schemas.FCMToken.CodingKeys
- Components.Schemas.FCMToken.installation_idPayload
- Components.Schemas.FCMTokenResponse.CodingKeys
- Components.Schemas.FCMTokenResponse.installation_idPayload
- Components.Schemas.InboxConfig.CodingKeys
- Components.Schemas.InboxConfig.imagesPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.bannerPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.dialogPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.footerPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.headerPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.iconPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload._defaultPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload._defaultPayload.hoverPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload._defaultPayload.statePayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unreadPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unreadPayload.hoverPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unreadPayload.statePayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unseenPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unseenPayload.hoverPayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.notificationPayload.unseenPayload.statePayload.CodingKeys
- Components.Schemas.InboxConfig.themePayload.unseenBadgePayload.CodingKeys
- Components.Schemas.Links.CodingKeys
- Components.Schemas.SlackFinishInstallResponse.CodingKeys
- Components.Schemas.SlackInstallation.CodingKeys
- Components.Schemas.SlackInstallation.authed_userPayload.CodingKeys
- Components.Schemas.SlackInstallation.enterprisePayload.CodingKeys
- Components.Schemas.SlackInstallation.incoming_webhookPayload.CodingKeys
- Components.Schemas.SlackInstallation.teamPayload.CodingKeys
- Components.Schemas.SlackStartInstall.CodingKeys
- Components.Schemas.SlackStartInstallResponseContent.CodingKeys
- Components.Schemas.SlackToken.CodingKeys
- Components.Schemas.SlackToken.oauthPayload.CodingKeys
- Components.Schemas.SlackToken.webhookPayload.CodingKeys
- Components.Schemas.SlackTokenResponse.CodingKeys
- Components.Schemas.SlackTokenResponse.oauthPayload.CodingKeys
- Components.Schemas.SlackTokenResponse.webhookPayload.CodingKeys
- Components.Schemas.TeamsToken.CodingKeys
- Components.Schemas.TeamsToken.webhookPayload.CodingKeys
- Components.Schemas.TeamsTokenResponse.CodingKeys
- Components.Schemas.TeamsTokenResponse.webhookPayload.CodingKeys
- Components.Schemas.TemplatesInstallation.CodingKeys
- Components.Schemas.WebPushStartInstallationResponse.CodingKeys
- Components.Schemas.WebPushToken.CodingKeys
- Components.Schemas.WebPushToken.keysPayload.CodingKeys
- Components.Schemas.WebPushTokenResponse.CodingKeys
- Components.Schemas.WebPushTokenResponse.keysPayload.CodingKeys
- Operations
- Operations.discard_mobile_push_apns_token
- Operations.discard_mobile_push_apns_token.AcceptableContentType
- Operations.discard_mobile_push_apns_token.Output
- Operations.discard_mobile_push_apns_token.Output.Ok.Body
- Operations.discard_mobile_push_expo_token
- Operations.discard_mobile_push_expo_token.AcceptableContentType
- Operations.discard_mobile_push_expo_token.Output
- Operations.discard_mobile_push_expo_token.Output.Ok.Body
- Operations.discard_mobile_push_fcm_token
- Operations.discard_mobile_push_fcm_token.AcceptableContentType
- Operations.discard_mobile_push_fcm_token.Output
- Operations.discard_mobile_push_fcm_token.Output.Ok.Body
- Operations.discard_slack_token
- Operations.discard_slack_token.AcceptableContentType
- Operations.discard_slack_token.Output
- Operations.discard_slack_token.Output.Ok.Body
- Operations.discard_teams_token
- Operations.discard_teams_token.AcceptableContentType
- Operations.discard_teams_token.Output
- Operations.discard_teams_token.Output.Ok.Body
- Operations.discard_web_push_token
- Operations.discard_web_push_token.AcceptableContentType
- Operations.discard_web_push_token.Output
- Operations.discard_web_push_token.Output.Ok.Body
- Operations.finish_slack_installation
- Operations.finish_slack_installation.AcceptableContentType
- Operations.finish_slack_installation.Input.Body
- Operations.finish_slack_installation.Output
- Operations.finish_slack_installation.Output.Created.Body
- Operations.get_mobile_push_apns_token
- Operations.get_mobile_push_apns_token.AcceptableContentType
- Operations.get_mobile_push_apns_token.Output
- Operations.get_mobile_push_apns_token.Output.Ok.Body
- Operations.get_mobile_push_apns_tokens
- Operations.get_mobile_push_apns_tokens.AcceptableContentType
- Operations.get_mobile_push_apns_tokens.Output
- Operations.get_mobile_push_apns_tokens.Output.Ok.Body
- Operations.get_mobile_push_expo_token
- Operations.get_mobile_push_expo_token.AcceptableContentType
- Operations.get_mobile_push_expo_token.Output
- Operations.get_mobile_push_expo_token.Output.Ok.Body
- Operations.get_mobile_push_expo_tokens
- Operations.get_mobile_push_expo_tokens.AcceptableContentType
- Operations.get_mobile_push_expo_tokens.Output
- Operations.get_mobile_push_expo_tokens.Output.Ok.Body
- Operations.get_mobile_push_fcm_token
- Operations.get_mobile_push_fcm_token.AcceptableContentType
- Operations.get_mobile_push_fcm_token.Output
- Operations.get_mobile_push_fcm_token.Output.Ok.Body
- Operations.get_mobile_push_fcm_tokens
- Operations.get_mobile_push_fcm_tokens.AcceptableContentType
- Operations.get_mobile_push_fcm_tokens.Output
- Operations.get_mobile_push_fcm_tokens.Output.Ok.Body
- Operations.get_slack_token
- Operations.get_slack_token.AcceptableContentType
- Operations.get_slack_token.Output
- Operations.get_slack_token.Output.Ok.Body
- Operations.get_slack_tokens
- Operations.get_slack_tokens.AcceptableContentType
- Operations.get_slack_tokens.Output
- Operations.get_slack_tokens.Output.Ok.Body
- Operations.get_teams_token
- Operations.get_teams_token.AcceptableContentType
- Operations.get_teams_token.Output
- Operations.get_teams_token.Output.Ok.Body
- Operations.get_teams_tokens
- Operations.get_teams_tokens.AcceptableContentType
- Operations.get_teams_tokens.Output
- Operations.get_teams_tokens.Output.Ok.Body
- Operations.get_web_push_token
- Operations.get_web_push_token.AcceptableContentType
- Operations.get_web_push_token.Output
- Operations.get_web_push_token.Output.Ok.Body
- Operations.get_web_push_tokens
- Operations.get_web_push_tokens.AcceptableContentType
- Operations.get_web_push_tokens.Output
- Operations.get_web_push_tokens.Output.Ok.Body
- Operations.save_inbox_installation
- Operations.save_inbox_installation.AcceptableContentType
- Operations.save_inbox_installation.Input.Body
- Operations.save_inbox_installation.Output
- Operations.save_inbox_installation.Output.Created.Body
- Operations.save_mobile_push_apns_token
- Operations.save_mobile_push_apns_token.AcceptableContentType
- Operations.save_mobile_push_apns_token.Input.Body
- Operations.save_mobile_push_apns_token.Output
- Operations.save_mobile_push_apns_token.Output.Created.Body
- Operations.save_mobile_push_expo_token
- Operations.save_mobile_push_expo_token.AcceptableContentType
- Operations.save_mobile_push_expo_token.Input.Body
- Operations.save_mobile_push_expo_token.Output
- Operations.save_mobile_push_expo_token.Output.Created.Body
- Operations.save_mobile_push_fcm_token
- Operations.save_mobile_push_fcm_token.AcceptableContentType
- Operations.save_mobile_push_fcm_token.Input.Body
- Operations.save_mobile_push_fcm_token.Output
- Operations.save_mobile_push_fcm_token.Output.Created.Body
- Operations.save_slack_installation
- Operations.save_slack_installation.AcceptableContentType
- Operations.save_slack_installation.Input.Body
- Operations.save_slack_installation.Output
- Operations.save_slack_installation.Output.Created.Body
- Operations.save_slack_token
- Operations.save_slack_token.AcceptableContentType
- Operations.save_slack_token.Input.Body
- Operations.save_slack_token.Output
- Operations.save_slack_token.Output.Created.Body
- Operations.save_teams_token
- Operations.save_teams_token.AcceptableContentType
- Operations.save_teams_token.Input.Body
- Operations.save_teams_token.Output
- Operations.save_teams_token.Output.Created.Body
- Operations.save_templates_installation
- Operations.save_templates_installation.AcceptableContentType
- Operations.save_templates_installation.Input.Body
- Operations.save_templates_installation.Output
- Operations.save_templates_installation.Output.Created.Body
- Operations.save_web_push_installation
- Operations.save_web_push_installation.AcceptableContentType
- Operations.save_web_push_installation.Input.Body
- Operations.save_web_push_installation.Output
- Operations.save_web_push_installation.Output.Created.Body
- Operations.save_web_push_token
- Operations.save_web_push_token.AcceptableContentType
- Operations.save_web_push_token.Input.Body
- Operations.save_web_push_token.Output
- Operations.save_web_push_token.Output.Created.Body
- Operations.start_inbox_installation
- Operations.start_inbox_installation.AcceptableContentType
- Operations.start_inbox_installation.Output
- Operations.start_inbox_installation.Output.Created.Body
- Operations.start_slack_installation
- Operations.start_slack_installation.AcceptableContentType
- Operations.start_slack_installation.Input.Body
- Operations.start_slack_installation.Output
- Operations.start_slack_installation.Output.Created.Body
- Operations.start_web_push_installation
- Operations.start_web_push_installation.AcceptableContentType
- Operations.start_web_push_installation.Output
- Operations.start_web_push_installation.Output.Created.Body
- Servers
- Servers.Server1
Extensions
This file was generated by SourceDocs