Skip to main content

Groups (iOS SDK)

A Group lets you treat multiple secure components as a single unit. The Group API supports two distinct use cases:

  • Validation - checking that two or more fields hold identical values (for example, password and confirm-password) without exposing the underlying plaintext.
  • Bulk tokenization - submitting several secure fields to Weavr in a single call and receiving one token per field.

UXComponents.createGroup and the Group class are part of the Weavr Components SDK.

Create a group

Pass the components you want to group. Group members can be any tokenizable secure components - for example, two SecurePasswordTextField views for a password-confirmation flow:

let passwordGroup = UXComponents.createGroup(
components: [passwordField, confirmPasswordField]
)

Manage group membership

Components can be added after the group has been created - useful when fields appear conditionally (for example, an extra security question that only some users see):

passwordGroup.addComponents(components: [securityAnswerField])

Validating that fields match

match() returns true when all components currently in the group contain identical values. Typical use is wiring it to your form's submit action:

@IBAction func submitTapped(_ sender: UIButton) {
if passwordGroup.match() {
// Inputs are identical - proceed to tokenize and submit.
} else {
showAlert(title: "Passwords don't match")
}
}

match() is a local-only check - it doesn't tokenizeTokenize Replace a card's primary account number (PAN) with a unique digital token that stands in for the real card during a transaction. When a cardholder adds a card to Apple Pay or Google Pay via push provisioning, the wallet provider stores a device-specific token rather than the underlying PAN, so the real card number isn't exposed on the device or shared with merchants. the fields or contact our backend.

Bulk tokenization

createToken tokenizesTokenize Replace a card's primary account number (PAN) with a unique digital token that stands in for the real card during a transaction. When a cardholder adds a card to Apple Pay or Google Pay via push provisioning, the wallet provider stores a device-specific token rather than the underlying PAN, so the real card number isn't exposed on the device or shared with merchants. every component in the group in one call and returns a dictionary keyed by the field keys you supply. Provide one entry in fieldKeys per component, in the same order the components were added to the group - the resulting dictionary associates each key with the token for that component:

passwordGroup.createToken(
fieldKeys: ["password", "passwordConfirm"]
) { weavrResponse in
switch weavrResponse {
case let .success(tokens):
let passwordToken = tokens["password"]
let confirmToken = tokens["passwordConfirm"]
// Submit the tokens to your backend.
case let .failure(error):
print("Tokenization failed:", error.message ?? "")
}
}
Field-key count must match component count

The number of entries in fieldKeys must equal the number of components currently in the group. Mismatched counts cause the call to fail.