Skip to content

Instantly share code, notes, and snippets.

@FromAtom
Last active August 25, 2019 08:52
Show Gist options
  • Save FromAtom/d6a0f39d0cdb41b2affeb851f5724138 to your computer and use it in GitHub Desktop.
Save FromAtom/d6a0f39d0cdb41b2affeb851f5724138 to your computer and use it in GitHub Desktop.
RPBroadcastActivityViewController のサンプルコード
import UIKit
import ReplayKit
class ViewController: UIViewController {
private var broadcastController: RPBroadcastController?
private func startBroadcast() {
RPBroadcastActivityViewController.load { broadcastAVC, error in
guard let broadcastAVC = broadcastAVC else { return }
broadcastAVC.delegate = self
self.present(broadcastAVC, animated: true)
}
}
private func finishBroadcast() {
broadcastController?.finishBroadcast(handler: { (error) in
print(error)
})
broadcastController = nil
}
}
extension ViewController: RPBroadcastActivityViewControllerDelegate {
func broadcastActivityViewController(_ broadcastActivityViewController:
RPBroadcastActivityViewController, didFinishWith broadcastController: RPBroadcastController?, error: Error?) {
self.broadcastController = broadcastController
self.broadcastController?.delegate = self
DispatchQueue.main.async {
broadcastActivityViewController.dismiss(animated: true) {
broadcastController?.startBroadcast { error in
print(error)
}
}
}
}
}
extension ViewController: RPBroadcastControllerDelegate {
func broadcastController(_ broadcastController: RPBroadcastController, didFinishWithError error: Error?) {
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment