Build Status Carthage compatible

Documentation | LICENSE

Requirements

  • iOS 8.0+
  • Xcode 9.0+
  • Swift 4.0

Install

Carthage

github "tvoli/iOS-MagineWhiteLabelSDK" >= 3.8.0

Always use latest stable release of Carthage.

Manual

  • Download and unzip MagineKit.framework.zipfrom releases
  • Add MagineKit.framework to Embedded Binaries

Since the SDK contains multiple architectures in order to work in the Simulator, it would need to be stripped in a Run Script Phase before deploying to the App Store.

Carthage comes with a script that copies over the relevant architectures into Embedded Binaries from Linked Frameworks and Libraries when compiling with a Run Script Phase

App Store does not currently support multiple architecture frameworks embedded. You can read more about it here here.

Setup

To begin with using MagineKitSDK one will initially need to setup some configurations.

Info.plist

You need to whitelist * magine.com * cloudfront.net

In the info.plist. xml <dict> <key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>example.com</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSExceptionRequiresForwardSecrecy</key> <false/> <key>NSIncludesSubdomains</key> <true/> <!-- Optional: Specify minimum TLS version --> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>TLSv1.2</string> </dict> </dict> </dict> </dict>

Read more about NSAppTransportSecurity.

Application Credentials (clientID & clientSecret)

Contact integration@magine.com for your magineClientId and magineClientSecret.


  let exampleConfig   = MagineKitConfiguration(client: (id:"...", secret:"..."))

  let tokenAfterLogin = "...."
  exampleConfig.session.credentialStore.set(token: tokenAfterLogin)
  self.magineKit = MagineKit(withConfiguration: self.exampleConfig)
  let magineRootViewController = self.magineKit.makeRootViewController(usingAPIPath: "root-vod")!
  self.presentViewController(magineRootViewController, animated: true)

To present an authorized player after tapping sign in button on previous player “`objective-c _weak typeof(self) weakSelf = self; [self.kitConfig setOnSignInButtonTapped:^(UIViewController * unauthorizedPlayerController, PlayableAsset * asset) { UIViewController * presenter = unauthorizedPlayerController.presentingViewController; [weakSelf.kitConfig.session.credentialStore setWithToken:@"eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOiJiZWluLXByb2R1Y3Rpb24tcG9jIiwic3ViIjoiYmVpbi1wcm9kdWN0aW9uLXBvYyIsImlhdCI6MTQ3NjE5ODM4NCwiZXhwIjoxNTM5MjYzNjAyfQ.1mg4C509b11sGxkU-rvtnprI8wpUmqbNsFxnlGp5Ia5Nf-PqmzgPTYsRBgOHE560TyizNzu3lvMOhKuWTZJIg” withUser:nil];

[unauthorizedPlayerController dismissViewControllerAnimated:YES completion:^{
    UIViewController *  newPlayerController = [[[MagineKit alloc] initWithConfiguration:weakSelf.kitConfig] makePlayerControllerWithPlayableAsset:asset];
    [presenter presentViewController:newPlayerController animated:YES completion:nil];

}];

}];


## Usage

### UI
The MagineKitSDK components follow [Apple's view controller hierarchy](https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/TheViewControllerHierarchy.html#//apple_ref/doc/uid/TP40007457-CH33-SW1) and is agnostic to containers.

### Authentication token

Before using the SDK it will need to be set up with an authentication token, this is used to authenticate against the Magine API's. If ```nil``` is passed as a parameter, the token will be cleared.

```swift
self.exampleConfig.session.credentialStore.set(token: "...")

The token needs to be refreshed every 24 hours, call this method again with new token.

Browse

The browse component UI stack is data driven. The views will have a different layout depending on the API response structure.

Browse allows you to discover different categories of content and its underlying assets. Selecting an asset will present a player.

  let kit = MagineKit(withConfiguration: self.yourConfig)
  kit.makeRootViewController(usingAPIPath: "root-vod")

To create the browse view stack, a path for the API has to be provided. The make signature returns a UIViewController. Contact integration@magine.com for more information about what paths are available to you.

Browse is designed to support all Apple navigation stacks, e.g.

  • UINavigationController
  • UITabBarController
  • UISplitViewController

Theme

There is a boilerplate theme file that can be used as a starting point.

Localization

To enable localization use the keys defined in Localizable.strings.