Get your iOS app connected to social.plus in just a few steps. This guide covers everything from installation to your first authenticated session.

Requirements

  • Xcode 14.3+
  • iOS 13.0+
  • Swift 5.0+

Installation

Objective-C Integration

Starting with v6.0.0, AmitySDK for iOS is written in Pure Swift. You can still use it in Objective-C projects by creating a Mixed-Language Project.
We recommend integrating AmitySDK directly into your Objective-C project and using Swift language to call the SDK interfaces for better compatibility and performance.

Mixed Language Project Setup

Create Swift files with necessary interfaces/methods that interact with AmitySDK. These interfaces should be exposed with @objc or @objcMembers attributes. When you add a new Swift file to your Objective-C project, Xcode automatically generates a bridging header file that exposes your Swift code to Objective-C.

Implementation Example

Create a Swift file that wraps AmitySDK functionality:
// SDKLoginManager.swift
// Example of a Swift file which contains a class to interact with AmitySDK

import AmitySDK

@objc class SDKLoginManager: NSObject {
    
    let client: AmityClient?
    
    @objc init(apiKey: String) {
        self.client = try? AmityClient(apiKey: apiKey)
    }
    
    @objc func login(userId: String, displayName: String, authToken: String, completion: @escaping (Bool, Error?) -> Void) {
        self.client?.login(userId: userId, displayName: displayName, authToken: authToken, completion: completion)
    }
    
    @objc func logout() {
        self.client?.secureLogout()
    }
    
    @objc func isLoggedIn() -> Bool {
        return self.client?.sessionState == .established ?? false
    }
    
    @objc func getCurrentUserId() -> String? {
        return self.client?.getCurrentUserId()
    }
}

Key Considerations

Next Steps

Troubleshooting