iOS Story Quick Start Guide

Quick Start Guide for Integrating Social Plus UIKit's Story Feature into iOS Applications

Welcome to the Quick Start Guide for integrating Social Plus's Story feature into your existing iOS application using Swift Package Manager (SwiftPM). This guide assumes that you have basic knowledge of iOS development and Xcode.

Prerequisites

  1. Xcode version 15+ is installed on your macOS system.

  2. An existing iOS project or create a new one for this integration.

  3. A valid Social Plus account and an API key. If you haven’t already registered for a Social Plus account, we recommend following our comprehensive step-by-step guide here in the Social Plus Portal to create your new network.

Step 1: Create or Open Your Project

  • Launch Xcode and either create a new iOS project or open an existing one where you wish to integrate the Story feature.

Step 2: Add Social Plus UIKit Package Dependency

  • Go to File > Swift Packages > Add Package Dependency.

  • Enter the repository URL for AmityUIKit: https://github.com/AmityCo/Amity-Social-Cloud-UIKit-iOS-SwiftPM.

  • Choose the appropriate version or branch and then add the package to your project.

Step 3: Import Social Plus UIKit

In your Swift file where you want to use the Story feature, import the Social Plus UIKit:

import AmityUIKit

Step 4: Setup Required Permissions

Your application needs the following permissions to access camera, microphone, and photo library:

  • In your info.plist, add the following keys with appropriate descriptions:

    • NSCameraUsageDescription

    • NSMicrophoneUsageDescription

    • NSPhotoLibraryUsageDescription

Step 5: Initialize Social Plus UIKit

Before using any features of the UIKit, you need to initialize it with your API key and optional configuration settings.

import AmityUIKit
import AmitySDK

AmityUIKitManager.setup(apiKey: "your_api_key_here", region: .global)

Optionally, you can specify endpoints manually if required by your application's needs.

Step 6: Authenticate

To use the SDK features, including the Story feature, register the current device with a user ID.

AmityUIKitManager.registerDevice(withUserId: "USER_ID", displayName: "DISPLAY_NAME", authToken: "AUTH_TOKEN")

Step 7: Integrate Story Feature

Integrating the Story feature involves utilizing the AmityStoryTabComponent and AmityCreateStoryPage for story creation and display.

  • For displaying stories related to a specific community:

let storyTabComponent = AmityStoryTabComponent(storyFeedType: .community(community))
let viewController = SwiftUIHostingController(rootView: storyTabComponent)
  • For navigating to the story creation page, specify a target community ID:

let createStoryPage = AmityCreateStoryPage(targetId: "community-id", avatar: avatarImageURL)
let viewController = SwiftUIHostingController(rootView: createStoryPage)

Step 8: Customizing the UI

Social Plus UIKit supports extensive customization options via a config.json file. You can modify themes, colors, and icons for various components and elements of the story feature according to your application's design requirements.

  • Example customization snippet:

"global_theme": {
  "light_theme": {
    "primary_color": "#FFFFFF",
    "secondary_color": "#AB1234"
  }
}
  • You can exclude certain UI elements or customize specific components and elements as per your needs.

You have now successfully integrated the Social Plus Story feature into your iOS application. For further customization options, refer to the detailed documentation provided with the SDK. If you encounter any issues or require assistance, our community forum at community.amity.co is always here to help.

Last updated