Phonelink

PhoneLink (iOS)

API reference for the PhoneLink Swift SDK.

The main interface for configuring and starting phone verification.

PhoneLink.configure(_:)

Set your client ID. Call once at app launch before any verification calls.

PhoneLink.configure("your-client-id")
ParameterTypeDescription
clientIDStringYour Phonelink client ID

PhoneLink.verify(completion:)

Start the phone verification flow. Opens a secure ASWebAuthenticationSession where the user enters their phone number and verifies it.

PhoneLink.verify { result in
    // handle result
}
ParameterTypeDescription
completion(PhoneLinkResult) -> VoidCalled when verification completes or fails

PhoneLink.verify(phoneNumber:completion:)

Start verification with a prefilled phone number. The user skips the number entry screen and goes directly to the verification code screen.

PhoneLink.verify(phoneNumber: "+14155551234") { result in
    // handle result
}
ParameterTypeDescription
phoneNumberStringPhone number to prefill in E.164 format
completion(PhoneLinkResult) -> VoidCalled when verification completes or fails

PhoneLinkResult

The result returned in the verification completion handler.

PropertyTypeDescription
phoneNumberString?The verified phone number in E.164 format
tokenString?Signed JWT for server-side validation
errorPhoneLinkError?The error, or nil on success

On success, phoneNumber and token are populated and error is nil. On failure, error is set and the other properties may be nil.


PhoneLinkError

An enum describing what went wrong during verification.

CaseDescription
.notConfiguredPhoneLink.configure(_:) was not called before verifying
.cancelledUser dismissed the verification screen
.missingTokenVerification completed but the response did not contain a token
.sessionFailed(Error)The underlying ASWebAuthenticationSession failed. The associated value contains the original error.

Example

PhoneLink.verify { result in
    if let error = result.error {
        switch error {
        case .notConfigured:
            print("Not configured")
        case .cancelled:
            print("Cancelled")
        case .missingToken:
            print("Missing token")
        case .sessionFailed(let underlying):
            print("Session failed: \(underlying)")
        }
    }
}

On this page