iOS

Add the Mati button to your iOS app.

Mati iOS Usage Guide

The following describes how to install and use the Mati iOS SDK for your application.

iOS Demo App

You can go to GitHub and download the Mati iOS demo app

Requirements and size

iOS 12+
Xcode 12.0
Swift 5.0

SDK compiled size: ~10MB

Source (in project files): 55MB

Add the Mati SDK

Install Using CocoaPods

Create a Podfile and add the pod Mati-Global-ID-SDK:

pod 'Mati-Global-ID-SDK'

Update your pods from the terminal

pod install

Note The following dependencies will be automatically installed with the pod Mati-Global-ID-SDK:

  • Starscream
  • SocketIO

Implement Mati in Your App

Add the Mati button to your App.

IMPORTANT Info.plist
Add the following permissions to capture video, access the photo gallery, and access the microphone for the voiceliveness feature.

<key>NSCameraUsageDescription</key>
<string>Mati needs access to your Camera</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Mati needs access to your media library</string>
<key>NSMicrophoneUsageDescription</key>
<string>Mati needs access to your Microphone</string>

Set the following parameters for your application:

ParameterTypeRequiredExample
matiButton.titlestringRequiredmatiButton.title = "Verify Me"
matiButton.textColorUIColorOptionalmatiButton.textColor = .white
matiButton.buttonColorUIColorOptionalmatiButton.buttonColor = .black
Metadata
Note Go to the Metadata section
to learn more about using metadata
@Nullable MetadataOptional

Note Be sure to initialize the Mati button before use.

Swift

import UIKit
import MatiSDK

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setupMatiButton()
    }

    private func setupMatiButton() {

      //init button
      let matiButton = MatiButton()

      //add button action
      matiButton.addTarget(self, action: #selector(self.matiButtonAction), for: .touchUpInside)

      //set view of button
      matiButton.frame = CGRect(x: 20, y: self.view.frame.size.height/2 - 50, width: view.frame.size.width - 40, height: 50)

      //add button to yours view
      view.addSubview(matiButton)

      //set delegate to get result
      MatiButtonResult.shared.delegate = self

    }

      @objc private func matiButtonAction() {
    //set params to showMatiFlow
    Mati.shared.showMatiFlow(clientId: "YOUR_CLIENT_ID",
                flowId: "YOUR_FLOW_ID",
                metadata: ["key1": "value1", "key2": 123])
    }
}

//MARK: MatiButtonResultDelegate
extension ViewController: MatiButtonResultDelegate {

    func verificationSuccess(identityId: String) {
        print("Mati Verification Success \(identityId)")
    }

    func verificationCancelled() {
        print("Mati Verification Cancelled")
    }
}

Objective-C



    #import "ViewController.h"
    #import <MatiSDK/MatiSDK.h>

    @interface ViewController () <MatiButtonResultDelegate>

    @property (nonatomic, strong) MatiButton *matiButton;

    @end

    @implementation ViewController

      - (void)viewDidLoad {
          [super viewDidLoad];

          //init button
          self.matiButton = [[MatiButton alloc] init];

          //add action to yours button
            [self.matiButton addTarget:self action:@selector(matiButtonAction:) forControlEvents:UIControlEventTouchUpInside];

          //set view of button
          self.matiButton.frame = CGRectMake(20, self.view.frame.size.height/2 - 25, self.view.frame.size.width - 40, 50);
          self.matiButton.center = self.view.center;

           //add button to yours view
          [self.view addSubview:self.matiButton];

          //set delegate to get result
          [MatiButtonResult shared].delegate = self;
      }

      //add showMatiFlow function with YOURS parameters
      -(void)matiButtonAction:(UIButton *) sender{
        [Mati.shared showMatiFlowWithClientId:@"YOUR_CLIENT_ID" flowId:@"YOUR_FLOW_ID"  metadata:@{@"key1":@"value"}];
    }

    #pragma mark - MatiButtonResultDelegate

      -(void)verificationSuccessWithIdentityId:(NSString *)identityId {
          NSLog(@"Success: [email protected]", identityId);
      }

      - (void)verificationCancelled {
          NSLog(@"Cancelled");
      }

    @end;

Metadata Usage

0) Metadata – is used as an additional parameter for sending it to you via a webhook after passing verification and is also displayed in the verification on the dashboard

1) You can use metadata to set specific parameters, including setting your default language and to hide language settings from users.

key: fixedLanguage
value: locale code of language

For instance, to set the language code for Spain to Spanish, we would set the fixedLanguage parameter to es"

Example: Set the Language Code for Spain

Swift

metadata: ["fixedLanguage": "es"]

2) Or you can set color of main buttons in flow you want.

2.1) Set the background color of button

key: buttonColor
value: hexColor

Example

Swift

metadata: ["buttonColor": "#C0C8D1"]

2.2) Set the title color of button

key: buttonTextColor
value: hexColor

Example

Swift

metadata: ["buttonTextColor": "#C0C8D1"]

Did this page help you?