Setup & Authentication
With Amity UIKit 2.3, we have introduced a new way to Authentication process. Just follow the guide below.

Adding required permissions

Your app may require the following permissions to work properly;
    1.
    Camera access
    2.
    Microphone access
    3.
    Photo library usage access
Before submitting your application to the store, please make sure the following permissions are already granted. Here are the steps to ask for permission.
Locate the info.plist file and add:
    1.
    NSCameraUsageDescription
    2.
    NSMicrophoneUsageDescription
    3.
    NSPhotoLibraryUsageDescription

Setup API Key

AmityUIKit requires an API key. You will need a valid API key to begin using the UIKit. You can find your account API key in the Amity Social Cloud Console.
1
import AmityUIKit
2
3
// in order to use AmityRegionalEndpoint enum, importing AmitySDK is required.
4
import AmitySDK
5
6
AmityUIKitManager.setup(
7
apiKey: "YOUR_API_KEY",
8
httpUrl: AmityRegionalEndpoint.EU, // optional param, defaulted as SG region
9
socketUrl: AmityRegionalEndpoint.EU // optional param, defaulted as SG region
10
)fAmityUIKitManager.setup
Copied!
AmityUIKitManager.setup should only be called once when app starts running. Calling the method repeatedly will create connection problems.

Specify Endpoints Manually (Optional)

You can specify endpoints manually via optional parameters. API endpoints for each data center are different so you need to adjust the endpoint accordingly.
We currently support multi-data center capabilities for the following regions:
Region
Endpoint
Endpoint URL
Europe
AmityRegionalEndpoint.EU
api.eu.amity.co
Singapore
AmityRegionalEndpoint.SG
api.sg.amity.co
United States
AmityRegionalEndpoint.US
api.us.amity.co

Authentication

To use any SDK feature, you must first register the current device with an userId. A device registered with an userId will be permanently tied to that userId until you explicitly unregister the device, or until the device has been inactive for more than 90 days. A device registered with a specific userId will receive all messages belonging to that user.
Additionally, an optional displayName can be provided if you wish to have this user identified in push notifications.
1
AmityUIKitManager.registerDevice(withUserId: "USER_ID", displayName: "Ali Connors", authToken: "AUTH_TOKEN")
Copied!

Unregister

In the event that your user logs out, you should explicitly unregister the user from the SDK as well, to prevent the current device from receiving any unnecessary or restricted data.
1
AmityUIKitManager.unregisterDevice()
Copied!
Last modified 25d ago