Skip to content

iOS and tvOS Integration

iOS and tvOS Integration

Peer5 integrates with iOS and tvOS apps in a straightforward and simple way. Peer5 installs a proxy between your video player and your stream which intercepts network requests and proxies them through a P2P mesh network.

Hybrid Application

Peer5 supports hybrid applications. Peer5 has a plugin integration for Cordova/Ionic as well as solutions for other hybrid application frameworks. The native app SDK is also tested with hybrid applications. Integrating with a hybrid app is simple and easy.

Delivery of content via P2P will work on all Apple devices running iOS 11.0 and up and tvOS 11.0 and up (versions with WebRTC support). Peer5's SDK falls back on native video delivery on older versions of iOS and tvOS as well.

React Native Application

Integration through React Native depends on whether you're performing video playback using an HTML5 player or a native player.

If you're using an HTML5 player, please follow the hybrid app instructions. For native playback, please follow the native application instructions below.

Native Application

Peer5 SDK Architecture

Player requests for video segments (.ts files) are intercepted and load balanced between HTTP and P2P.

Supported technologies

  1. Player: Any iOS player
  2. iOS / tvOS Version: 9+ (P2P supported from 11+)
  3. Streaming Protocol: HLS

Installation instruction with CocoaPods

  1. Add pod 'Peer5Kit', 'X.X.X' to your podfile. (XXX stands for the library version)
  2. Run pod install

Integration instructions

  1. In your AppDelegate.m or AppDelegate.swift add a reference to Peer5Kit:

    • Objective C: #import "Peer5Kit/Peer5Sdk.h"
    • Swift: import Peer5Kit
  2. Initialize the Peer5 SDK to an instance or static variable:

    • Objective C: sdk =[[Peer5Sdk alloc] initWithToken:@"API-TOKEN"];
    • Swift: sdk = Peer5Sdk(token: "API-TOKEN")
  3. When initializing an AVPlayer (or other video player) instance, before passing it a URL, pass that URL through Peer5:

    • Objective C: NSURL *newUrl = [sdk streamURLForURL :original];
    • Swift: let newUrl = sdk.streamURL(forURL: original)

    Then use the newUrl variable as the new URL for the player.

  4. In order to allow the loading of distributed content via the Peer5 proxy, enable loading data from HTTP in your app by opening your info.plist file as source code and adding the following values below the </dict> tag:


Or alternatively, from the UI editor:

That’s it. Peer5 should now be integrated into your app. You can confirm that it’s working by going to your Peer5 dashboard and filtering traffic by platform, either "iOS" or "tvOS". Note that the SDK instance should be bound to the application’s lifetime.

Whitelisting Peer5

Requests from the Peer5 iOS SDK to the CDN will originate from the or domain, depending on your integration. If you have referrer block configured in the CDN, please also whitelist the & domains so requests will be able to bypass that authentication.

Questions & Answers

Q: How can i check that the SDK is integrated correctly?

A: Log into your Peer5 account at, then go to the Realtime Analytics tab and click on the "Add a filter+” link in the top-left corner of the page. Select "Platform Name” as your filter and choose either "iOS” or "tvOS”, depending on your integration. After a correct integration you should see traffic there. Traffic may take several minutes to start appearing in the dashboard.

Q: Who do i contact regarding integration questions?

A: Use your direct communication channel with Peer5. If you are not sure who your direct contact is, please contact us at

Q: How can I gradually deploy P2P with the SDK?

A: You can change the percentage of users who have peer-to-peer delivery enabled from your Peer5 dashboard at Note that this change can be made even after you have deployed your app.

Q: How do I change the way Peer5 runs in cellular networks?

A: You can change the behavior of Peer5 for users who are connected via cellular from your Peer5 dashboard at

Q: Is the SDK stable? Should I expect any performance difference in my app?

A: Peer5’s iOS SDK is battle tested in real world applications and contains an extensive test suite that runs on each version. Integrating the SDK should have no performance impact on your application. Users, on the other hand, will enjoy higher quality streaming with the SDK.

Q: How does Peer5 work?

A: Please refer to

Q: Which iOS versions do you support?

A: For iOS: iOS 9+ is supported. P2P sharing works on iOS 11+. For tvOS: tvOS 9+ is supported. P2P sharing works on tvOS 11+. If you require support for lower versions, please contact us (

Q: Is tvOS supported?

A: Yes, tvOS is supported! You can the Peer5 SDK for tvOS just like you use it for iOS.

Q: How long does integration take?

A: The code integration typically takes less than an hour.

Q: Why do I get an error for incompatible architectures?

A: Peer5 ships a "fat framework" with Peer5Kit.framework containing both x86 and ARM builds so you can test the code both on a real device or an emulator. When installing the SDK with CocoaPods it takes care of the architecture differences automatically when submitting to the app store.

Some customers have reported that uninstalling and reinstalling the pods before creating the archive solved this issue for them.

Q: Does AirPlay work?

A: Peer5 does not directly support AirPlay at the moment but it is easy to make Peer5 work with AirPlay in an app. The way to do this is to only use the Peer5 URL when the app is not airplaying. First, listen to the player reacting to external playback events:

[player addObserver:self forKeyPath:@"externalPlaybackActive" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];

Then, add a KVO listener to set the URL back to the original playlist URL before sending it to AirPlay:

- (void)observeValueForKeyPath:(NSString *)keyPath
                       change:(NSDictionary *)change
                      context:(void *)context {
   if (![keyPath isEqualToString:@"externalPlaybackActive"]) {
       return; // not external playback
   if (change[@"old"] == change[@"new"]) {
       return; // no value change
   if (player.isExternalPlaybackActive) {
       [player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:original]];
       // airplay started - set URL to original version
   else {
       [player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithURL:rewritten]];
       // airplay stopped - set URL to result of streamURLforURL

Q: I have more questions, where can I get more information?

A: Please refer to for additional information.