# Nonstop Swift SDK

## Nonstop Home

Nonstop Home can be opened by calling:

```swift
    Nonstop.sharedInstance.presentNonstopHome(delegate: self)
```

This will open the Nonstop Home experience which is fully managed by the SDK.

### Nonstop Home Delegate

The `presentNonstopHome` method requires a class which implements `NonstopHomeDelegate` to be passed to it. Currently this delegate does not contain any methods, however, we may add methods to it to support future SDK features.

### Deeplinking

By default Nonstop Home opens on the Earn tab. To open it on another tab, pass a value from the `NonstopHomeTab` enum to the `presentNonstopHome` method:

```swift
    Nonstop.sharedInstance.presentNonstopHome(tab: .History, delegate: self)
```

Additionally, for certain deeplinks it may be necessary to open Nonstop Home at a particular promo or on the redeem code screen. In this case, pass an instance of `NonstopHomeAction` to the `presentNonstopHome` method:

```swift
    let nonstopHomeAction = NonstopHomeAction(type: .OpenPromo, contentId: id)
    Nonstop.sharedInstance.presentNonstopHome(tab: .Earn, delegate: self, action: nonstopHomeAction)
```

## History Widget (tvOS Only)

The history items from Nonstop Home History can be rendered as a separate widget for including in other areas of the app. The widget will require a logged in Nonstop User.

### How To Use

The history widget can be added using a Storyboard or via code.

To use via a Storyboard, simply include a view in the Storyboard and set it's custom class to be `NonstopHistoryView`.

To use via code, create a `NonstopHistoryView` and then add it as a subview to the current view. For example:

```swift
    let historyView = NonstopHistoryView()
    view.addSubview(historyView)
```
