Skip to content

acoustic-content-samples/content-delivery-ios-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Acoustic Content Delivery iOS SDK

iOS SDK for the Acoustic Content Delivery API.

Motivation

This SDK is designed to help utilize the content hosted in Acoustic Content libraries in mobile applications (headlessly).

Getting started

This document is intended to help to understand how to use Acoustic Content SDK in your own projects.

Add the SDK to your project

  1. There are several ways how to add the SDK to your own projects:

    • As source code:

      • Copy Classes folder into your project. Rename if needed.
      • Use SDK classes directly without importing them
    • As Xcode Project dependency:

      • Drag&drop SDK XCode project to your project
      • Go to Project settings -> TARGETS -> Your target -> Build Phases
      • Add SDK into Dependencies and Link Binary With Libraries groups
    • As part of Xcode Workspace in form of Xcode Project dependency

      • perform actions from previous list but against Project Workspace
    • As regular or emdedded Framework:

      • Build regular Framework
      • or build Fat Framework (refer iOS SDK Fat Framework How-To document)
      • or extract framework on XCFramework making step from appropriate outputs/platform_device.xcarchive and outputs/platform_simulator.xcarchive files (in Finder tap Show Package Contents and go to Products->Library->Frameworks folder)
      • Refer Embedding Frameworks In An App document from list below
      • Pay attention to Embed & Code Sign option if needed
    • As XCFramework:

      • Build XCFramework (refer iOS SDK XCFramework How-To document)
      • Drag&drop xcframework to your project
      • Refer Embedding Frameworks In An App document from list below
      • Pay attention to Embed & Code Sign option if needed
      • Please pay attention that in your exact case XCFramework may require additional configuration or rebuilding.

      Important: At the moment the script make_framework contains the actual iOS version for the current iOS SDK installed. You may need to update it according to your current iOS SDK installed on your workstation.

  2. This information about Frameworks may be helpful:

    1. Embedding Frameworks In An App
    2. Framework Programming Guide
  3. Import the SDK

import AcousticContentSDK

How to instantiate the SDK

  1. Create API URL:
let url = URL(string: "https://myX.content-cms.com/api/0000-0000-0000-0000-0000")!
  1. Create configuration for SDK:
let config = AcousticContentSDK.Config(apiURL: url)
  1. Create SDK instance:
let sdk = AcousticContentSDK(withConfig: config)

How to login

  1. Use login in case SDK requires accessing authenticates resources:
sdk.login(username: "username", 
          password: "password") 
{ (success, error) in
    print("Login \(success ? "succeeded" : "failed")")
}
  1. Use logout when needed:
sdk.logout()

How to run a basic query

Now the SDK is ready to retireve data.

  1. Create instance of DeliverySearch class
let deliverySearch = sdk.deliverySearch()
  1. Get artifact provider (ex.: contentItems), configure request by calling Configurable functions:
deliverySearch.contentItems()
        .filterByName("Peru*")
        .rows(15)
        .sortBy("name", ascending: false)
        .get { (result) in
            ...
    }
  1. Retrieve result and process it:
.get { (result) in

    // 1. Process error
    guard result.error == nil else { return }
    
    // 2. Use data
    print("Retrieved \(result.numFound) items")
    print("Items: \(result.documents.compactMap({$0.name}).joined(separator: ", "))")
    
    // 3. Prepare next page request provider
    nextItems = result.nextPage()
}
  1. Retrieve next page:
nextItems?.get(completion: { (result) in
    // ...
    nextItems = result.nextPage()
})

How to run the SDK Sample app

  1. Navigate to AcousticContentSDKSample folder
  2. Find and open AcousticContentSDKSample.xcworkspace

Important: since AcousticContentSDKSample is organized in form of Xcode Workspace please pay attention that you do not need to open AcousticContentSDKSample.xcodeproj

  1. When Xcode with sdk workspace open - navigate to AppDelegate.swift file
  2. Find AcousticContent helper class and edit appropriate baseUrl and tenantId

Important please pay attention to existing form of every constant: baseURL - it is a domain name with preceding https://

  1. Select AcousticContentSDKSample scheme and click Run.

About

iOS SDK for the Acoustic Content Delivery API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages