Authenticate channel
Initialize
To initialize the Proto iOS SDK, complete the following steps:
- Under the SETTINGS tab, copy the GATEWAY_ID (Channel ID)

- 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:
- 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)!)
})
- Get the User ID:
let userId = PTUserService.getInstance().getUserId()
- Get the access token:
let accessToken = PTUserService.getInstance().getAccessToken()
- Get the gateway ID:
let gatewayId = Proto.getInstance().getGatewayId()
- Get the Firebase device token:
let firebaseToken = Proto.getInstance().getFirebaseToken()
Updated about 2 years ago
What’s Next