> For the complete documentation index, see [llms.txt](https://docs.snapodds.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapodds.com/docs/mobile-sdk/ios/snapodds-sport-media/snapping-games-and-presenting-odds.md).

# Snapping Games and Presenting Odds

## Implementation

1. Verify the SDK is initialized.
2. Retrieve an instance of `SnapViewController` with your desired (or the default) `SnapConfiguration`
3. Present the `SnapViewController` (the recommended presentation is modally in a `UINavigationController`)

## Live Game Capture And Odds Display Code Example

The following code illustrates a `SnapViewController` with the default configuration.

```swift
let snapViewController = SnapViewController.forSportsMedia(configuration: SnapConfiguration())
snapViewController.isModalInPresentation = true
snapViewController.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancelSnap))
self.present(UINavigationController(rootViewController: snapViewController), animated: true, completion: nil)
```

If you do not want or need to customize the snapping configuration, you can also omit the `configuration` parameter.

Once a sporting event is successfully snapped, the `OddsResultsViewController` is automatically pushed in the `UINavigationController` and the odds for the snapped game are presented.

If the sporting event is not successfully snapped, an error message will appear in the viewfinder:\
&#x20;*"Your snap returned no results. Make sure your TV is visible in the viewfinder"*

### Camera Permissions Required before Presenting Snap

Applications must request user permission for camera access, and camera access is required for the app to function. For this reason, your application should be set to ask permission from the user to access the camera, and to receive said permission, before presenting the Snap UI. The following code will set your application to request and receive permission prior to opening Snap UI:

```swift
let status = AVCaptureDevice.authorizationStatus(for: .video)
switch status {
  case .authorized:
      presentSnap()
  case .notDetermined:
      AVCaptureDevice.requestAccess(for: .video) { [weak self] (granted) in
          DispatchQueue.main.async { [weak self] in
              if granted {
                  self?.presentSnap()
              } else {
                  presentAlertWithLinkToSettings()
              }
          }
      }
  case .denied: fallthrough
  case .restricted:
      presentAlertWithLinkToSettings()
  @unknown default:
      presentSnap()
}
```

## Recommendations

### Present Snap in a UINavigationController

SnapOdds recommends presenting`SnapViewController` in a `UINavigationController`. Please note that SnapViewController itself does not present any cancellation item within the UI. The developer of the application is responsible for configuring a cancel item on the presented `UINavigationController`.

### Limit to portrait

Currently, Snap UI is optimized only for portrait orientation. We recommend that you limit the supported interface orientations for the presented UINavigationController to portrait only.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.snapodds.com/docs/mobile-sdk/ios/snapodds-sport-media/snapping-games-and-presenting-odds.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
