Skip to Content
iOS OptionsActivity Collection

Activity collection

Set GraffityARCloudConfiguration.userId to your stable player ID to enable tap-to-collect for collectible content authored in Graffity Console. This ID also scopes user-specific content requests.

import GraffityARCloud @MainActor final class CollectionSession: @preconcurrency GraffityARCloudDelegate { let sdk: GraffityARCloud init(accessToken: String, playerId: String) throws { sdk = try GraffityARCloud(configuration: GraffityARCloudConfiguration( accessToken: accessToken, mode: .arContent, userId: playerId )) sdk.delegate = self } func graffityARCloud( _ sdk: GraffityARCloud, didCollect contentId: String, activity: GraffityARActivity ) { print("Collected: \(contentId)") print("Progress: \(activity.collectedContentIds.count)/\(activity.maxCollectionSize)") if activity.isFinished { // Present your app's completion UI. print("Finished activity: \(activity.id)") } } func graffityARCloud(_ sdk: GraffityARCloud, didFailWith error: GraffityARCloudError) { print(error.localizedDescription) } }

Retain CollectionSession and host its SDK view as in the quick start. Without userId, tap-to-collect cannot submit a player collection. Ordinary content still needs a collection effect to become collectible.

Collection result

GraffityARActivity is Sendable, Codable, and Equatable:

PropertyTypeMeaning
idStringActivity identifier.
projectIdStringProject or campaign.
playerIdStringParticipating player.
isFinishedBoolActivity completion.
collectedContentIds[String]Already collected content.
maxCollectionSizeIntRequired collection size.
bannerImageURLURL?Optional banner image.
collectionEmptyImageURLURL?Optional empty-slot image.
collectionActiveImageURLURL?Optional filled-slot image.
lastModifiedDate?Last server modification.

Use the result for your app’s progress or completion UI. Collection works with default telemetry: .disabled.