Get started

Methods presented in this part are available in the DriveKitChallenge class

Prerequisite

Before starting DriveKit Challenge module integration, make sure that you have initialized DriveKit.

If you use DriveKit Challenge without having initialized DriveKit, the SDK may not work properly in your application.

Integration

Get framework

DriveKit Challenge module is available on CocoaPods master repo.

To access the framework in the repository, add the following lines to your Podfile:

target 'my-target' do
  pod 'DriveKitChallenge'
end

Then, run pod install.

Synchronize list of challenges

To synchronize the list of challenges, call the following method:

DriveKitChallenge.shared.getChallenges(
   type: SynchronizationType = .defaultSync,
   completionHandler: @escaping (ChallengesSyncStatus, [DKChallenge]) -> Void
)

ChallengesSyncStatus and DKChallenge models are described in the References part.

Take a look at the open-source code of our DriveKit Demo App to see how it is implemented.

Retrieve local challenge list

You can retrieve the list of challenges stored in the DriveKit local database by calling the previous method but with the SynchronizationType parameter to .cache.

Synchronize challenge detail

You need to call the following method if you want to get more details and statistics about a defined challenge:

DriveKitChallenge.shared.getChallengeDetail(
   challengeId: String,
   type: SynchronizationType = .defaultSync,
   completionHandler: @escaping (ChallengeDetailSyncStatus, DKChallengeDetail?) -> Void
)

This method have the following parameters:

FieldTypeDescription

challengeId

String

Unique identifier of the challenge

synchronizationType

SynchronizationType

Can be .defaultSync or .cache.

- .defaultSync will synchronize the challenge detail by calling the DriveQuant servers

- .cache will retrieve the challenge detail already synchronized in the local database.

ChallengeDetailSyncStatus and DKChallengeDetail models are described in the References part.

Take a look at the open-source code of our DriveKit Demo App to see how it is implemented.

Retrieve local challenge detail data

You can retrieve the details of a given challenge stored in the DriveKit local database by calling the previous method but with the SynchronizationType parameter to .cache.

Join a challenge

To be able to join a given challenge, you can call the following method:

DriveKitChallenge.shared.joinChallenge(
   challengeId: String,
   completionHandler: @escaping (JoinChallengeSyncStatus) -> Void
)

This method have the following parameter:

FieldTypeDescription

challengeId

String

Unique identifier of the challenge

JoinChallengeSyncStatus enum values are described in the References part.

Take a look at the open-source code of our DriveKit Demo App to see how it is implemented.

Reset

If you need to reset the Challenge module configuration (user logout for example), you can call the following method:

DriveKitChallenge.shared.reset()

All data saved locally by the Challenge module will be erased.

Last updated