Installation and Authentication

This section outlines how you can set up your SP project and contains all the tutorial links you'll need to get going.

SDK Installation

For instructions on installing the Social Plus SDK, refer to the installation guide for your platform.

We are constantly working to improve our existing SDKs. For this reason, the minimum compatibility for our previous versions may vary. Below is the compatibility list for our latest SDKversions. For a complete overview of the compatibility of a specific SDK version, please refer to the corresponding Changelogs.

  • Xcode Version: 14.3

  • Realm Version: 10.28.3

  • Minimum Target: iOS 13.0

Initialization

Before you can use the SP SDK you just installed, we'll first need to create a new SDK instance with your API key. Please find your account API key in the Social Plus Console or visit our Social+ Console page.

After logging into the Console:

  1. Click Settings to expand the menu.

  2. Select Security.

  3. On the Security page, you can find the API key in the Keys section.

API key in Security page

If you have trouble finding this, you can post in our community forum at community.social.plus.co so our support team can assist you.

let client = try! AmityClient(apiKey: "api-key", region: .SG)

Specify Endpoints Manually (Optional)

By default, AmityClient will connect to AmityRegion.SG.You can specify endpoints manually via AmityEndpoint struct. API endpoints for each data center are different so you need to adjust the endpoint accordingly.

let endpoint = AmityEndpoint(httpUrl: "http-endpoint",
                              rpcUrl: "rpc-endpoint",
                            mqttHost: "mqtt-host")
let client = try! AmityClient(apiKey: "api-key", endpoint: endpoint)

We currently support multi-data center capabilities for the following regions:

Region

Endpoint

Europe

AmityRegion.EU

Singapore

AmityRegion.SG

United States

AmityRegion.US

Specify database encryption mode (Optional)

The SDK does not employ database encryption by default. The database file is solely restricted to the application by the operating system, which is generally sufficient for most use cases. Database encryption serves as an additional layer of security in the event of compromised root access. It's important to note that enabling database encryption may lead to a performance reduction of up to 15% during database read/write operations.

Please note that we only support database encryption for Android SDK 5.35.0 and v6, beginning from version 6.16.0 onwards.

Database Encryption Modes:

The SDK offers three encryption modes:

  1. NONE: No encryption is applied.

  2. AUTH: Access token storage is encrypted.

  3. ALL: All database files are encrypted.

AUTH mode is recommended to introduce extra security with minimal performance compromise. Ultimately, the chosen encryption mode should align with your application's specific requirements.

Encryption key:

Enabling database encryption necessitates an encryption key. It is imperative to consistently pass the same key to the SDK. Should a new key be supplied, the existing database file will be erased and subsequently regenerated, encrypted with the new key.

The level of security offered by encryption hinges on the method of key generation and storage employed by the application. It is strongly recommended to adhere to industry standards for both key storage and generation.

Authentication

To use any SP SDK feature, you must first log in to the current device with a userId. A logged-in device will be tied to the userId until the device is either proactively logged out, or until the device has been inactive for over 90 days. A logged-in device will receive all the event messages belonging to the tied user.

An optional displayName can be provided, which will be used in standard push notifications (related to the user's actions, such as when a new message is sent).

An authToken is also highly recommended to always be provided, which will be used for secure authentication. For more info on how to configure secure settings and obtain authToken, refer to our Security page.

A sessionHandler is required for SDK to communicate with the app. For more info please refer to Session Handler. Do note that the sessionHandler is not yet available for Flutter SDK.

A login example

The displayName is set only on the first time the device is logged in. Please follow your platform's necessary directions if you would like to rename this to something else.

Logout

When the user logs out, you should explicitly log out the user from the SDK as well. This prevents the current device from receiving unnecessary and/or restricted data.

client.logout()

Logout is a synchronous operation. Once the logout method is called, the SDK disconnects from the server and wipes out the user session.

Secure Logout

For an extra layer of security, the SDK provides secureLogout(), an asynchronous function, which ensures accessToken revocation prior to performing logout(). Should the SDK fail to revoke the accessToken, the SDK will not proceed to logout and will throw an exception to notify the failure.

Disconnect

After the SDK is logged in with a user, SDK will maintain the connection as long as it can. However the SDK connection can be terminated due to many reasons, for example:

  • The device lost its Internet connection.

  • Users close the app in the background, and then the operating system pauses the app and terminates all network connections.

By default, the SDK automatically reconnects itself whenever the app has a chance to get back online.

There are some use cases which developers need more control over the SDK connection. The SDK provides disconnect(). This method allows developers to explicitly disconnect the SDK while maintaining the current user session so that the app can later resume the connection with the same user.

client.disconnect()

When developers call disconnect():

  • The SDK will terminate server connections without logging out the current user.

  • The SDK will not automatically reconnect until the next login.

To resume the connection, the developers should call login(...) with the current user.

Devices

Each user can be logged in, at the same time, to an unlimited number of devices. Social Plus's Chat SDK will automatically synchronize the user data across all logged-in devices. We will also automatically log out any device that has not been connected to the server for more than 90 days.

When a device is logged out due to inactivity, the SDK data on the device will be reset. You will need to re-login this device in order to connect to the server again.

Tutorials

Now that you've finished getting your SP project set up, here are some step-by-step articles if you need a hand in building your app!

Visualized Code Examples

Yes, you're reading it right! Here you can visually learn how your changes could affect the code, compare your work, and see our development pattern recommendations.

Are you ready? Click here to explore.

All Your UIKit Needs

How to Create a Social App with ASC

Explore a step-by-step tutorial by our engineers to help you build your own Social application. Let's get started in creating an amazing user experience platform.

UIKit Open Source Repositories

Our UIKit is ready to customize and use, the only task left for you is the integration. We make it as simple as that. Let's dig in!

Creating Notifications and Webhooks with NodeJs

Push notifications are proven to be one of the best ways to drive & increase user engagement with the platform and with Social Plus. Read more...

Building an Android Image Feed Application

Engage your users through image activity feeds as known from known social networks like Instagram and Pinterest. Read more

Social Plus Developer Kits

Check out our Social Plus UI Kits and Template Apps.

  • UI Kits Our UI Kits include user interfaces to enable fast integration of standard Social Plus Chat and Social Plus Social features into new or existing applications.

  • Template Apps Our Template Apps are ready-made template applications to kickstart your own Social Plus project.

With real-life use cases, we guide you through ways you can get started with building stellar applications for yourself your clients, and their users.

Download our Developer Kits

Last updated

Was this helpful?