iOS SDK

HotMic offers an iOS SDK so you can let users inside your application watch your streams. This allows you to drive users to your own application, to retain control over your users, unlike in Twitch and Facebook,

To learn more, we recommend looking at our Sample App, which is the fastest way to see the iOS SDK in action inside a sample application.

Then, we recommend reviewing our SDK Installation Guide, found here: iOS SDK Installation Guide

iOS Sample App

HotMic offers a sample app to see how to use our iOS SDK in your application. Here is a step-by-step guide to downloading and running the HotMic SDK sample applications for iOS.

Requirements

  1. A link to the HotMic SDK sample application provided by HotMic.
  2. An API Key provided by HotMic.
  3. A JWT token created using a Secret provided by HotMic. Instructions for how to create the token can be found below.  
  4. A white labeled production dashboard where you will produce streams.  

Authentication with JWT Token

For security, when using the SDK your app controls authentication with a JWT Token, which you pass to HotMic.

JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. - jwt.io

You will receive an API Secret from HotMic, which you will use to create the token.  The token will be used to authenticate the user, as well as provide information such as their name, an avatar, a unique ID, or another information which is needed by the SDK. 

This is the expected format of the JWT token:

JS
|

Note, the user_id field should be consistent for each invocation of the SDK for that particular user.  

iOS Installation

  1. Unzip the HotMicMediaPlayerSample.zip file, and open MediaPlayerSample.xcworkspace in xCode.
  2. Open MediaPlayerSample/AppDelegate, and update apiKey and accessToken, inside the call to HMMediaPlayer.initialize.
  3. Install CocoaPods, and run pod install from the terminal in the MediaPlayerSample folder .
  4. Choose your target device or simulator in Xcode, and press Run
  5. You should see a few streams populate in the app.  Tap on one of them to load the media player. 
  6. See the installation guide for a more detailed description of the SDK.
  7. Use the Production Dashboard to create and start streams.  You can use the account ios-test1@hotmic.io/password to login, or sign up for a new account.



iOS SDK Installation

Here are instructions on how to install the iOS SDK. If you ever have issues installing the iOS SDK, please contact our team.

The name of our SDK is HotMicMediaPlayer. HotMicMediaPlayer allows you to integrate the HotMic player experience into your app. Use this framework to create a HMPlayerViewController for a specific stream and present it full screen.

Requirements

  • API Key and JWT Secret: Will be provided by HotMic.
  • iOS 12+
    • iPadOS user interface is not tailored to the iPad, its just a larger iPhone view. A future update will expand tablet support.
    • macOS apps are not supported.
  • Swift UIKit app
    • Integration in Objective-C or SwiftUI apps is not officially supported
  • App is already live on the App Store
    • HotMicMediaPlayer uses the UIWebView framework for YouTube playback. Apple does not allow new apps to use UIWebView. The reason UIWebView is used is due to the fact that WKWebView does not support all features needed for YouTube playback. This component can also be removed if YouTube playback is not required for your use-case.
  • App uses view controller based status bar appearance.
  • App supports portrait and landscape orientations.
  • App disables Bitcode
    • Because HotMicMediaPlayer uses ACRCloud which was built without full Bitcode support, HotMicMediaPlayer must disable Bitcode, and your app must as well

Accessibility

Accessibility support including Dynamic Type, VoiceOver, etc

App Privacy

When integrating HotMicMediaPlayer into your app, you must disclose the data it and its dependencies collect on the App Store:

  • Name - used for product personalization
  • Audio data - used for app functionality
  • Device ID - used for analytics
  • Advertising data - used for developer’s advertising or marketing, analytics, linked to the user’s identity
  • Other diagnostics data - used for app functionality, linked to the user’s identity

HotMicMediaPlayer has the following dependencies:

  • ACRCloudSDK
  • youtube-ios-player-helper
  • BitmovinPlayer
  • TrueTime
  • OpenTok
  • Shipbook
  • PubNub
  • FittedSheets
  • Kingfisher

If your team is already using 1 or more of these dependencies, please contact us so we can ensure to get you the right version of the HotMicMediaPlayer SDK that matches your dependencies.

CocoaPods

Add the following to your Podfile, then run pod repo update and then pod install

Swift
|

Privacy

Add the following keys to your target’s Info tab:

  • NSCameraUsageDescription - this is required to join the room with video
  • NSMicrophoneUsageDescription - this is required to join the room with audio and sync the stream with a TV

Capabilities

Add the following capabilities to your app’s target:

  • Background Modes - Audio, AirPlay, and Picture in Picture

In-app Purchases

HotMic supports two types of in-app purchases in the player experience: tip the host and join the stream. You can support these in your app as well. You will need to configure these in App Store Connect, then be sure to submit them to Apple for review alongside your app update.

API Key and Authorization Token

You will need an API key for your app to use the HotMic service. You will also need to create an authorization token. HotMic will provide you with the key and information on how to create the token in the appropriate format.  

Initialization

Initialize HMMediaPlayer with your API key and authorization token. This must be done before any other functions are called in HMMediaPlayer, so we recommend performing initialization in your AppDelegate’s didFinishLaunchingWithOptions. If needed, it can be called again later, for example if the token changes.

Swift
|

ApiKey

A UUID provided by HotMic. 

AccessToken

Use any JWT library to create a token.  Format is as follows:

JS
|

Get Streams

You can fetch streams from HotMic that are live, scheduled, and/or video-on-demand replays. You can optionally choose to get streams created by a specific user. Pagination is supported via optional limit and skip parameters. 

JS
|

Player View Controller

Initialize a HMPlayerViewController and present it:



Swift
|

Setting the modalPresentationStyle to a value other than fullScreen is not allowed.

The player view controller is presented in portrait mode, then after presentation it will support rotating to landscape. Note that the player may force rotate to portrait in the experience, for example, if a tall sheet needs to be presented.

Player View Controller Delegate

Swift
|

To support returning to the full-screen player experience from PiP, call HMPlayerViewController’s restorePiPView(:) function and then present the player view controller full screen:

Swift
|

To be informed when the user taps an ad in the stream, implement the following HMPlayerViewControllerDelegate function:

Swift
|

User Profile Delegate

To support following and unfollowing users from inside the HotMic experience, you can implement the HMMediaPlayerUserProfileDelegate protocol. If you do not implement this delegate, the follow/unfollow buttons will not be shown.

Swift
|

When a user profile is shown, the following function is called to get the “is following” state for the currently logged in user. Provide a success result with true if the logged in user is following the provided user, false if they are not following, or nil if follow/unfollow is not available for the provided user. Provide a failure result with an Error if one occurred.



Swift
|

When the user taps the follow or unfollow button, the following function is called allowing you to record the new following state. Provide an Error to the completion handler if one occurs.

Swift
|

In App Purchase Delegate

To support tipping hosts and joining their streams for a price, you can implement the HMMediaPlayerInAppPurchaseDelegate protocol and integrate it with your StoreKit in-app purchase code. If you do not implement this delegate, users cannot tip hosts, but can still join the host for free.

Swift
|

When the user opens the tip sheet, the following function will be called to get the SKProducts available to purchase for a host ID. Your app should fetch the products that are applicable to this host from the App Store.

Swift
|

When the user wishes to purchase a tip, the following function will be called. Your app should initiate the in-app purchase process. If the purchase is successful, your app should then submit the tip purchase information including the App Store receipt via HMMediaPlayer’s submitTipPurchase function. HotMic will verify this purchase is legitimate and record the tip if validated. Be sure to provide an error if one occurs in this process, such as if the device cannot make payments, a purchase is already in progress, the transaction was canceled, the transaction failed, failed to get transaction info, no purchase info was found, failed to verify, or failed to process. The completion handler allows you to specify if you want this error’s localizedDescription to be shown to the user and if a button should be provided to retry submitting their purchase information if that request fails. We strongly recommend persisting the purchase information on the device and avoid marking the SKPaymentTransaction finished until the purchase has been successfully submitted, as this allows you to retry submitting the information when StoreKit informs you there is a not-yet-finished purchased transaction.

Swift
|

When the user wishes to retry submitting their purchase information, the following function will be called. Your app should look up the purchase information with the provided product identifier and submit it via HMMediaPlayer’s submitTipPurchase function.

Swift
|

To support join stream in-app purchases, very similar functions as those for tips are available and should be used in the same way.

If you reach out to us we would be happy to provide you with more information and example code from our in-app purchase manager that will allow you to implement this the same way we did.

Analytics Event Observing

To be notified of analytics events as they occur throughout the experience, you can implement the HMMediaPlayerAnalyticsEventObserving protocol. Documentation for event names and info keys and values is not yet available.



Swift
|