How to Use IOS SDK

To use this SDK, please 

Embed this SafousWaap.xcframework

import this on class

import SafousWaap

Using SDK (Basic Syntax)


This is the basic syntax used in the SDK, and this is an example for the device registration process.

import SafousWaap

SafousWaap.shared. < Method > (
onSuccess: {
  response in
  // handling exception for success logic
  },

onError: {
  error in
  // error handling 
}
)

Initialize SDK Class


For declare class variables in the SDK, where is function in the class can’t be called without the intermediary of the class variable. This is the example :

SafousWaap * safousWaap = [
  [SafousWaap alloc] init
  ];

Declare Callback Variable


Process of Initialize or declare callback variable, an important process in the SDK which functions as a variable that will accommodate the response of the function or method that will be called. In this SDK there are 2 types of responses :

1. onSuccess

this function run when the return generated is a positive (+) Response, example : When you received an HTTP Response of 200.

2. onError

this function run when the result return generated is a negative (-) Response, example : When you received an HTTP response other than of 200, likes : 302, 401, 403, etc.

SafousWaap.shared. < Method > (
onSuccess: {
  response in
  // handling exception for success logic
  },

onError: {
  error in
// error handling
print(erorr.code)
  print(erorr.header)
  print(erorr.body)
}
)

Device Registration and Verification


This is the process for registration and verification to get validation from Safous Web Application and API Protection (WAAP) that the client is granted permission to backend.

Device Registration


There are some steps taken by the SDK in the device registration process which will result return Http Client framework. Http Client framework will be used by the application sending http request to the backend. See the code :

SafousWaap.shared.registerDevice(
  onSuccess: {
    response in
    print(response)
    },

  onError: {
    error in
    print(error)
  }
  )

Verification Device


Get Verify Token from the client verification app :

Process verification from backend need to do, so that the application is proven in accordance with the provisions of the backend. And in this process should be done by application (not in the SDK). The result from verify token is jwtVerifyToken to used in verification with Token by Safous and for the calling the method adjust in the application.

Verification with Token by Safous WAAP :

After get verify token from the client verification, the application will be sent jwtVerifyToken to SDK, so the SDK should bring jwtVerifyToken to Safous WAAP and Safous WAAP will register the application based on jwtVerifyToken. The result from verification with Token by Safous is http response of 200. See the code :

SafousWaap.shared.verifyDevice(
  headers: [: ],
  onSuccess: {
    response in
    print(response)
    },

  onError: {
    error in
    print(error)
  }
  )

Transaction to the Backend App


SafousWaap.shared.transaction(
  onSuccess: {
    response in
    print(response)
    },

  onError: {
    error in
    print(error)
  }
  )

Error response description :

Error Code

Message or Body

Description

-1

Message error from SDK

Get failed from SDK

example : Connection failure, failure generate cookies,etc

302

Found

user-cookies have problem or user-cookies not match

400

Invalid request

 

401

Unauthorised request

 

403

Failed to verify your device

 

Terminate


Terminate access token bearer

SafousWaap.shared.terminate(
  onSuccess: {
    response in
    print(response)
    },

  onError: {
    error in
    print(error)
  }
  )