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

Step 1 requires account approval

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 EverLink 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:

1) Detect Code

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


      // Other codes...
      @IBAction func startRecording(_ sender: Any) {
          //to start listening for a code call:
          
          connectObj.startRecording(isOffline: false)
          
      }
      // 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.

Function startRecording(isOffline); now takes a boolean as an argument, If this argument is true then the device will try to do the matching locally with any previously saved tokens, rather than contacting our servers; this will allow your users to be offline.

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", isOffline: false)
          
      }
      // Other codes...


Function startEmittingToken(token, isOffline) now takes a boolean as an argument. If this argument is true then the device will try to fetch the audio code it will emit locally, rather than contacting our servers, this will allow your users to be offline.

Create token

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


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


Function newToken(startDate) takes a validity start date in the form ‘YYYY-MM-DD’. The token will be valid for two weeks after this date. If no validity date is provided then it will be the current date.

We will return your identifying token via the onMyTokenGenerated method.

Downloading Tokens
(Only needed if you want the SDK to work offline)

To download the audio code associated with a token so it can later be played or detected offline, call function saveSounds() passing it an array of tokens:


     // Other codes...

     @IBAction func saveTokens(_ sender: Any) {
        //Save an array of tokens and their corresponding audio codes.
            
            let array = ["exampleToken12345", "exampleToken12346", "exampleToken12347"]

            connectObj.saveSounds(tokensArray: array)
     }

     // Other codes...

Call clearSounds() To delete all downloaded tokens and their corresponding audio codes