---
title: "#20: ReplayKit 🎥"
url: https://littlebitesofcocoa.com/20-replaykit
author: Jake Marsh
date: 2015-06-19
published: 2015-06-19
topics: ["ReplayKit","iOS 9"]
description: "ReplayKit in iOS 9 allows you to record a movie of what's happening on screen in your app or game. Here's a quick example of how to use it: Records app..."
---

# #20: ReplayKit 🎥

By Jake Marsh, June 19, 2015. HTML: https://littlebitesofcocoa.com/20-replaykit

**ReplayKit** in **iOS 9** allows you to record a movie of what's happening on screen in your app or game. Here's a quick example of how to use it:

``` swift
import ReplayKit

class GameViewController: UIViewController {
  func startRecording() {
    let recorder = RPScreenRecorder.sharedRecorder()
    recorder.startRecordingWithMicrophoneEnabled(true)
  }

  func stopRecording() {
    let recorder = RPScreenRecorder.sharedRecorder()

    recorder.stopRecordingWithHandler { (previewVC, error) in
      if let vc = previewVC {
        self.presentViewController(
          vc, 
          animated: true, 
          completion: nil
        )
      }
    }
  }
}
```

<img src="https://media.littlebitesofcocoa.com/bite-assets/020-replaykit-things-to-know.png" style="max-width: 260px;" />

- Records app audio, optionally also records microphone audio. The user is given the chance to preview and, edit , and trim the video before exporting.
- You can't access the movie file itself. After recording, user is shown an activity view controller, which you can add custom actions to.
- Recording is polite to battery and performance.
- Only works A7 and A8 devices.
- Permission from the user is required to begin recording.
- Recording automatically excludes system UI like notifications or keyboard entry.
