Authenticate channel

Initialize

To initialize the Proto iOS SDK, complete the following steps:

  1. Under the SETTINGS tab, copy the GATEWAY_ID (Channel ID)
424
  1. Import ProtoChat module in your AppDelegate.swift, you can initialize the SDK by calling the below method:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  
  // paste the gateway id in step 1 here
  Proto.init(GATEWAY_ID)
  return true
}

Authenticate

If you want to reuse Proto User Interface with full functionality without the need to implement the API yourself, you can skip to this section.
To authenticate the Proto iOS SDK, complete the following steps:

  1. Authenticate the user to get the access token in order to use other mobile APIs:
PTUserService.getInstance().authenticateUser(completion: {(authResponse, err) in
    guard err == nil else {
        print("False with code: \(String(describing: err?.mErrorCode)) and message: \(err?.mErrorMessage)")
        return
    }
    print("accessToken: " + (authResponse?.accessToken)! + " userId " + (authResponse?.userId)!)
})
  1. Get the User ID:
let userId = PTUserService.getInstance().getUserId()
  1. Get the access token:
let accessToken = PTUserService.getInstance().getAccessToken()
  1. Get the gateway ID:
let gatewayId = Proto.getInstance().getGatewayId()
  1. Get the Firebase device token:
let firebaseToken = Proto.getInstance().getFirebaseToken()

What’s Next