# Nonstop Swift SDK

## Choice Cards

Choice Cards control the logic around:

* Whether the user should be offered the choice of purchasing the content at all
* Whether the user has previously purchased the content and is still within their grace period
* Whether the user has enough points to purchase the content
* The user interface for presenting the choices to the user
* Whether the choice card includes a timer, and if so for how long
* Recording the user selection, including recording purchases
* Calling back the integrating application with instruction on path to take

Note: In some situations the actual Choice Card UI will not show at all, the calling client will simply be instructed to continue.

### When to call it

`presentChoiceCard` should be called prior to watching a long form on-demand stream when the user is logged in. The client should wait for a callback before proceeding.

`presentChoiceCard` is not required for Live, VPPO clips or ShowMS clips. When called for non-valid content or when no user logged in it will simply return the `onWatchStandard` callback.

### How to call it

```swift
Nonstop.sharedInstance.presentChoiceCard(contentId: "VDKA4220171", delegate: self)
```

* **contentId** - the PartnerAPIId of the content the user has selected to watch
* **delegate** - a class that implements NonstopChoiceCardDelegate. This should implement the following functions:

### Callbacks

#### Watch Nonstop

```swift
func onWatchNonstop(accessToken :String) {
    // Client should play the stream with Nonstop ad load
    // The accessToken should be sent to EIA Services
}
```

When the client application receives this callback it means that the user should watch the selected content Nonstop. This could be for a number of reasons:

* because they purchased via the choice card
* because they are within their grace period for this piece of content
* because this piece of content has been given to all users by a particular sponsor

The client application should instruct the player to commence with a reduced ad load by passing the `accessToken` value returned from the SDK to the player framework using the "**cbp_token**" parameter. See PlayingContentNonstop for more details.

#### Watch Standard

```swift
func onWatchStandard() {
    // Client should play the stream with normal ad load
}
```

When the client application receives this callback it means that the user should watch the selected content with the standard ad load. This could be for a number of reasons:

* this piece of content is not eligible to watch Nonstop
* the user could not afford to watch the content Nonstop
* the choice card timer elapsed and the user did not make a selection
* an error has occurred that is best to be handled by just playing the stream with standard ad load

The client application should instruct the player to commence with a normal ad load by not passing a value for "**cbp_token**" to the player framework.

#### Back Pressed

```swift
func onBackPressed() {
    // Client should show the Show or Movie screen for the given content
}
```

The user has clicked the back button, the containing app should navigate to the Show or Movie detail screen for the content the choice card is presenting. Note: Often the user will already be on that screen.
