# Rewards

The SDK allows for the host application to retrieve a token, which in turn can be used by the host application to fetch data from the Rewards system (see documentation for the Rewards). In order to fetch that token, the application must have a valid user (represented by the Identity). That user must be active.

### **Fetch Token**

To fetch the token, the following API can be used.

### **Concrete example**

{% tabs %}
{% tab title="Swift" %}

```swift
let rewards = RewardsService()
rewards.fetchToken(then: { result in
    let token = result.value.token
    guard !token.isEmpty else {
        // failure
        return
    }
    completionHandler(.success(token))
})
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rewards = RewardsService()
rewards.fetchToken(ResultCallback { result: Result<RewardToken?>? ->
    if (result?.value == null || result.throwable != null) {
        // failure
    } else {
        // Success
        val token = result.value.token
    }
})
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk.ims.tech/drivesync-portal/rewards.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
