Age Gate Module

Class PrivoAgeGate

Instance Method getStatus(userIdentifier:nickname:)

The method allows checking the existing Age Gate status.

func getStatus(
    userIdentifier: String?,
    nickname: String? = nil
) async throws -> AgeGateEvent

Return Value

AgeGateEvent

Parameters

userIdentifier - external user identifier (please don't use empty string ("") as a value. It will cause an error. We support real values or nil if you don't have it)
nickname - optional parameter with default value nil. Please, use nickname only in case of multi-user integration. Please don't use empty string "" in it.

Throws

There is only one exception type - PrivoError.

  • PrivoError.cancelled is thrown if cancelled with Task.cancel().
  • PrivoError.incorrectInputData(AgeGateError) is thrown if the data submitted for processing is not correct.

Discussion

Concurrency Note

You can call this method from asynchronous code. This method has similar one, which resembles the completion handler method for calling from synchronous code.

See more information about concurrency and asynchronous code in Swift.


Instance Method getStatus(userIdentifier:nickname:completionHandler:errorHandler:)

The method allows checking the existing Age Gate status.

func getStatus(
    userIdentifier: String?,
    nickname: String? = nil,
    completionHandler: @escaping (AgeGateEvent) -> Void,
    errorHandler: ((Error) -> Void)? = nil
)

Return Value

AgeGateEvent

Parameters

userIdentifier - external user identifier (please don't use empty string ("") as a value. It will cause an error. We support real values or nil if you don't have it)
nickname - optional parameter with default value nil. Please, use nickname only in case of multi-user integration. Please don't use empty string "" in it.
completionHandler - closure that is used to handle an asynchronous operation result and takes the AgeGateEvent instance as an input argument.
errorHandler - optional parameter with default value nil. Called instead of the completionHandler when an error occurs. Takes an Error instance as input argument.

Discussion

Concurrency Note

For calling method from asynchronous code you could use a similar.

See more information about concurrency and asynchronous code in Swift.


Instance Method run(_:)

The method runs the Age Gate check. If the birth date is passed by a partner or filled in by a user, the method will return the status. If the birth date is not passed, a user will be navigated to the corresponding entry window and forced to fill in the birthday field.

  run(_ data: CheckAgeData) async throws -> AgeGateEvent

Return Value

AgeGateEvent
Returns a status, which takes into consideration a user age and configuration parameters defined by a partner.

Parameters

data - instance of type CheckAgeData

Throws

There is only one exception type - PrivoError.

  • PrivoError.cancelled is thrown if cancelled with Task.cancel().
  • PrivoError.incorrectInputData(AgeGateError) is thrown if the data submitted for processing is not correct.

Discussion

Concurrency Note

You can call this method from asynchronous code. This method has a similar one, which resembles the completion handler method for calling from synchronous code.

See more information about concurrency and asynchronous code in Swift.


Instance Method run(_:completionHandler:)

The method runs the Age Gate check. If the birth date is passed by a partner or filled in by a user, the method will return the status. If the birth date is not passed, a user will be navigated to the corresponding entry window and forced to fill in the birthday field.

func run(
    _ data: CheckAgeData,
    completionHandler: @escaping (AgeGateEvent?) -> Void
)

Parameters

completionHandler - A closure to execute. Nil indicates that a failure occurred. Status parameter takes into consideration a user age and a configuration set defined by a partner.

Discussion

Concurrency Note

For calling method from asynchronous code you could use a similar.

See more information about concurrency and asynchronous code in Swift.


Instance Method recheck(_:)

The method allows rechecking data if the birth date provided by a user was updated.

func recheck(_ data: CheckAgeData) async throws -> AgeGateEvent

Return Value

AgeGateEvent

Parameters

data - instance of type CheckAgeData

Throws

There is only one exception type - PrivoError.

  • PrivoError.cancelled is thrown if cancelled with Task.cancel().
  • PrivoError.incorrectInputData(AgeGateError) is thrown if the data submitted for processing is not correct.
  • Could throws PrivoError.incorrectInputData(AgeGateError.agIdNotFound).

Discussion

Concurrency Note

You can call this method from asynchronous code. This method has a similar one, which resembles the completion handler method for calling from synchronous code.

See more information about concurrency and asynchronous code in Swift.


Instance Method recheck(_:completionHandler:)

The method allows rechecking data if the birth date provided by a user was updated.

func recheck(
    _ data: CheckAgeData,
    completionHandler: @escaping (AgeGateEvent?) -> Void
)

Parameters

completionHandler - a closure to execute. Nil indicates a failure has occured.

Discussion

Concurrency Note

For calling method from asynchronous code you could use a similar.

See more information about concurrency and asynchronous code in Swift.


Instance Method linkUser(userIdentifier:agId:nickname:)

The method links a user to specified userIdentifier. It is used in multi-user flow in case an account creation (on a partner side) happens after the Age Gate flow. Please note that linkUser can be used only for users that don't have userIdentifier yet. It is impossible to change the userIdentifier after it was obtained.

func linkUser(
    userIdentifier: String,
    agId: String,
    nickname: String?
) async throws -> AgeGateEvent

Return Value

AgeGateEvent

Parameters

userIdentifier - external user identifier (please don't use empty string ("") as a value. It will cause an error. We support real values or null if you don't have it)
agId - age gate identifier that you get as a response from sdk on previous steps
nickname - optional field, nickname (please use only in case of multi-user integration. Please don't use empty string "" in it)

Throws

There is only one exception type - PrivoError.

  • PrivoError.cancelled is thrown if cancelled with Task.cancel().
  • PrivoError.incorrectInputData(AgeGateError) is thrown if the data submitted for processing is not correct.

Discussion

Concurrency Note

You can call this method from asynchronous code. This method has a similar one, which resembles the completion handler for calling from synchronous code.

See more information about concurrency and asynchronous code in Swift.


Instance Method linkUser(userIdentifier:agId:nickname:completionHandler:errorHandler:)

The method will link a user to a specified userIdentifier. It is used in multi-user flow in case an account creation (on a partner side) happens after the Age Gate flow. Please note that linkUser can be only used for users that don't have userIdentifier yet. It is impossible to change the userIdentifier after it was obtained.

func linkUser(
    userIdentifier: String,
    agId: String,
    nickname: String?,
    completionHandler: @escaping (AgeGateEvent) -> Void,
    errorHandler: ((Error) -> Void)? = nil
)

Parameters

userIdentifier - external user identifier (please don't use empty string ("") as a value. It will cause an error. We support real values or null if you don't have it)
agId - age gate identifier that you get as a response from sdk on previous steps
nickname - optional field, nickname (please use only in case of multi-user integration. Please don't use empty string "" in it)
errorHandler - optional parameter with default value nil. Called instead of the completionHandler when an error occurs. Takes an Error instance as input argument.
completionHandler - closure that is used to handle an asynchronous operation result and takes the AgeGateEvent instance as an input argument.

Discussion

Concurrency Note

For calling method from asynchronous code you could use a similar.

See more information about concurrency and asynchronous code in Swift.


Instance method showIdentifierModal(userIdentifier:nickname:)

The method will show a modal dialog with user age gate identifier (can be used to contact customer support)

func showIdentifierModal(
    userIdentifier: String?,
    nickname: String? = nil
)

Parameters

userIdentifier - optional field, external user identifier (please don't use empty string ("") as a value. It will cause an error. We support real values or null if you don't have it)
nickname - optional field, nickname (please use only in case of multi-user integration. Please don't use empty string "" in it)


Instance method hide()

The method allows a partner to hide the Age Gate widget.

func hide()