Send Progress Event (Timed Event)

Timed Event challenges track the total time a user was playing a title while logged into Versus. Like every win condition, a time limit can be applied to this win condition. An example of this challenge would be: "Stay alive for 3 hours in the next 2 days."

Android

Method A: Send separate start play time and end play time events.

/**
* @property name Challenge / Event Name
* @return VsLiveData with a success bool
*/
fun startPlaytimeEvent(name: String): VsLiveData<ChallengeUpdated>
      

/**
* @property name Challenge / Event Name
* @return VsLiveData with a list of any affected challenges for the playtime event.
*/  
fun stopPlaytimeEvent(name: String): VsLiveData<List<Challenge>>
SDK.Challenge.startPlaytimeEvent("Challenge/Event Name")
  .observe(object : VsObserver<ChallengeUpdated>() {
    override fun onError(error: Throwable) {
    }

    override fun onChanged(t: Boolean) {
    }
})

SDK.Challenge.stopPlaytimeEvent("Challenge/Event Name")
  .observe(object : VsObserver<ChallengeUpdated>() {
    override fun onError(error: Throwable) {
    }

    override fun onChanged(t: Boolean) {
    }
})

Method B: Send start play and end play time events together.

/**
* @property name Challenge / Event Name
* @return VsLiveData with a list of affected challenges for this playtimeEvent.
*/
fun sendPlaytimeEvent(name: String, started: Date, ended: Date): VsLiveData<List<Challenge>>
val startDate = Date()
val endDate = Date()

SDK.Challenges.sendPlaytimeEvent("playTimeEventName", startDate, endDate)
  .observe(object : VsObserver<List<Challenge>>() {
    override fun onError(error: Throwable) {
    }

    override fun onChanged(t: List<Challenge>) {
    }
})

iOS

Method A: Send separate start play time and end play time events.

/// - Parameters:
/// - name: Name of the event
/// - completionHandler: Closure which returns a BOOL for success/failure updating the challenge.
startPlaytimeEvent(name: String, completionHandler: @escaping Challenge.ChallengeUpdatedHandler)
 
/// - Parameters:
///   - name: Name of the event
///   - completionHandler: Closure which returns a BOOL for success/failure updating the challenge.
stopPlaytimeEvent(name: String, completionHandler: @escaping VersusApiResponse<Challenge>)

Method B: Send start play and end play time events together.

/// - name: Name of the event
/// - completionHandler: Closure which returns a BOOL for success/failure updating the challenge.
sendInstantPlaytimeEvent(name: String, completionHandler: @escaping VersusApiResponse<Challenge>)