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, especially if you have disable the SDK auto-initialization.

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:

Field
Type
Description

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:

Field
Type
Description

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.

Last updated