Skip to content

A developer friendly sample implementation of Spark client SDK and showcases all SDK features.

License

Notifications You must be signed in to change notification settings

asynchrony/spark-ios-sdk-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kitchen Sink

Kitchen Sink Demo App is a developer friendly sample implementation of Spark client SDK and showcases all SDK features.

Setup

Here are the steps to setup Xcode project using CocoaPods:

  1. Install CocoaPods:

    gem install cocoapods
  2. Setup Cocoapods:

    pod setup
  3. Install SparkSDK and other dependencies from your project directory:

    pod install

Example

The "// MARK: " labels in source code have distinguished the SDK calling and UI views paragraphes.
Below is code snippets of the SDK calling in the demo.

  1. Setup SDK with Spark access token

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
         let sparkAccessToken = "Yjc5ZTYyMDEt..."
         Spark.initWith(accessToken: sparkAccessToken)
         return true
     }
  2. Setup SDK with app infomation, and authorize access to Spark service

    class LoginViewController: UIViewController {
         @IBAction func loginWithSpark(sender: AnyObject) {
             let clientId = "C90f769..."
             let clientSecret = "64e252..."
             let scope = "spark:people_read spark:rooms_read spark:rooms_write spark:memberships_read spark:memberships_write spark:messages_read spark:messages_write"
             let redirectUri = "KitchenSink://response"
             
             Spark.initWith(clientId: clientId, clientSecret: clientSecret, scope: scope, redirectUri: redirectUri, controller: self)
         }
     }
  3. Register device

    Spark.phone.register() { success in
        if !success {
            print("Failed to register device.")
        }
    }
  4. Spark calling API

     // Self video view and Remote video view
     @IBOutlet weak var selfView: MediaRenderView!
     @IBOutlet weak var remoteView: MediaRenderView!
     
     // Make a call
     let call = Spark.phone.dial(email, option: MediaOption.AudioVideo(local: videoCallViewController.selfView, remote: videoCallViewController.remoteView)) { success in
         if !success {
             print("Failed to dial call.")
         }
     }
     
     // Recive a call
     class IncomingCallViewController: UIViewController, PhoneObserver {
     override func viewWillAppear(...) {
         PhoneNotificationCenter.sharedInstance.addObserver(self)
     }
     override func viewWillDisappear(...) {
         PhoneNotificationCenter.sharedInstance.removeObserver(self)
     }
     func callIncoming(call: Call) {
         // Show incoming call toast view
     }
     
     // Answer and reject call
     call.answer(option: MediaOption.AudioVideo(local: videoCallViewController.selfView, remote: videoCallViewController.remoteView), completionHandler: nil)
     call.reject(nil)

Note

  1. Strip unsupported achitecture before submitting to App store:

    Wme framework of media engine in SDK contains a build for both the simulator (x86_64) and the actual devices (ARM).
    Of course, you aren't allowed to submit to the App Store a binary for an unsupported achitecture, so the solution is to "manually" remove the unneeded architectures from the final binary, before submitting it.
    Daniel Kennett came up with a nice solution and provides this script to add to the build phase.
    http://stackoverflow.com/questions/30547283/submit-to-app-store-issues

    Note this script only work in Release scheme and use for achive binary.

About

A developer friendly sample implementation of Spark client SDK and showcases all SDK features.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 98.1%
  • Ruby 1.9%