Main white everlink logo
text_snippet Examples
Coming soon
text_snippet Examples
Coming soon

Create ultra-contactless token communication

(!) BEFORE GETTING STARTED

flash_on You should have a token based iOS app.

Guide focus: Setting up Everlink’s iOS SDK to enable sonic-key to token exchange.

There are two core elements to consider in this process, Set Up and Usage.

flash_on Prerequisites

Make sure that have the following:
  1. Xcode 11.0 or later

  2. CocoaPods 1.9.0 or later

  3. A project that targets iOS 9.0 or later.

Set Up: Please follow the steps below to get started:

flash_on The Everlink SDK uses the microphone to record audio. Add Privacy - Microphone Usage Description in the info.plist file for microphone access.

1) Add EverLink SDK to your app

Create a Podfile if you don't already have one:


    $ cd  your-project-directory


    $ pod init

Add the Everlink SDK to your Podfile and install the Everlink SDK to your project as follows:


   // Other codes...
    
    target 'My Sample App' do
    // Other codes...
    pod 'EverlinkBroadcastSDK', '0.1.5'
      
   end


   $ pod install

After installing the pods, open your .xcworkspace file to see the project in Xcode:


   $ open your-project.xcworkspace

From now onwards as your project contains a dependency managed by CocoaPods, you must use the .xcworkspace file to open the project, not .xcodeproj.

CONGRATS you’ve now set-up Everlink! Now onto usage.


Usage: After the client app is set up, you are ready to begin verifying and identifying devices, you can now:

  1. Detect codes
  2. Send codes
The EverLinkConnect class has a number of methods that you can use to send and receive audio codes. We do all audio code generation, token checks and returns, and stop listening on code detection automatically.

The code below demonstrates how to add Everlink to an existing ViewController.
Change all instances of ViewController example with the name of your View Controller, and let myAppID to your key, which you can find in the account page:


    import UIKit
    import EverlinkBroadcastSDK
     
    class ViewController: UIViewController, EverlinkConnectDelegate {
        
        let myAppID = "12345"
        
        let connectObj = EverlinkConnect(appID: myAppID)
        
        override func viewDidLoad() {
            super.viewDidLoad()
            // Other codes...
            connectObj.delegate = self
            // Other codes...
        }
        
        func onAudioCodeReceived(token: String) {
        // you can now identify, via the server returned token, what location/device was heard
            print(token)
        }
        
        func onMyTokenGenerated(token: String) {
            //a new token generated, to save in your database
            print(token)
        }
        
    }


1) Detect Code

When you want to detect an audio code simply call: startRecording();


      // Other codes...
      @IBAction func startRecording(_ sender: Any) {
          //to start listening for a code call:
          
          connectObj.startRecording()
          
      }
      // Other codes...
      @IBAction func stopRecording(_ sender: Any) {
          //to stop listening call:
          
          connectObj.stopRecording()
          
      }
      // Other codes...


Which will cause the device to start listening for an audio code, on successful detection we will return the identifying token of the heard device via the onAudioCodeReceived method.

2) Send Code

When you want to start emitting an audio code simply call: startEmitting();


      // Other codes...
      @IBAction func playSound(_ sender: Any) {
          //to start emitting an audio code call:
          
          connectObj.startEmitting()
          
      }
      // Other codes...
      @IBAction func stopPlaying(_ sender: Any) {
          //to stop emitting call:
          
          connectObj.stopEmitting()
          
      }
      // Other codes...


You can alternatively pass a token as an argument and its audio code will play, as shown below:


      // Other codes...
      @IBAction func playToken(_ sender: Any) {
          //to start emitting an audio code call:
          
          connectObj.startEmittingToken(token: "exampleToken12345")
          
      }
      // Other codes...


If you wish to manually generate a new user token call: newToken();

      
      // Other codes...
      @IBAction func newToken(_ sender: Any) {
          //Generate a new user token to save in your database
          
          connectObj.newToken()
          
      }
      // Other codes...


We generate new tokens automatically, and also swap the associated audio code often for security reasons so manual calls are not needed. We will return your identifying token via the onMyTokenGenerated method.