@takeoffmedia/react-native-penthera
v0.8.2
Published
test
Downloads
294
Readme
@takeoffmedia/react-native-penthera
This document provide information about the Penthera SDK implementation, we built 2 custom react native wrappers for iOS and Android using the Penthera native SDK
Penthera Cloud
Penthera Cloud (backplane), the SDK handles the requests to the Penthera Cloud from the SDK initialization, user login, downloads and so on.
Definition concepts
userID: An unique string identifier of user provided by us, Penthera will use this value to identify and associate any interaction of the SDK with the logged user.
deviceID: An unique string identifier of the device.
asset: Any content downloaded or added to the download quote will be saved as an asset object in Penthera local storage, with an unique string identifier to handle the status of the assets.
VirtuosoHTTPClient: a static http client solution to handle the streaming of the local HLS video format.
iOS
requirements
- iOS 10 +
setup
Add the Penthera repository source to the Podfile:
source 'https://github.com/penthera/Download2Go-specs.git'
Add the framework to the Podfile:
source 'https://cdn.cocoapods.org/'
source 'https://github.com/penthera/Download2Go-specs.git'
pod 'VirtuosoClientDownloadEngine', :git => 'https://github.com/penthera/Download2Go-ios', :branch => 'master'
#ALTERNATIVE - Specify a specific version of Penthera SDK
#pod 'VirtuosoClientDownloadEngine', '~> 4.2'
Run pod install command.
Then add to the AppDelegate.mm the VirtuosoClientDownloadEngine.
#import <React/RCTAppSetupUtils.h>
#import <VirtuosoClientDownloadEngine/VirtuosoClientDownloadEngine.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//…
// Initialize engine and fetch a handle to the singleton instance
VirtuosoDownloadEngine* engine = [VirtuosoDownloadEngine instance];
// Global “on switch” for downloading
[engine setEnabled:YES];
}
Info.plist
In your app’s info.plist:
Add “Application Uses Wifi” and set it to YES.
In “Required Background Modes”, add the option “App downloads content in response to push notifications”.
In “Required Background Modes”, add the option “App downloads content from the network”.
Initialization
In our wrapper solution we provided a method to instantiate the SDK, the next parameters are required:
userId: logged user identifier
backplaneUrl: the url of the Penthera Cloud
publicKey: provided by Penthera
privateKey: provided by penthera
externalDeviceID: Optional deviceID provided by us
This method will return a success message in case the initialization is successful otherwise it will return one of the following errors code:
| Fruit | Description | |-------| -------| | PENTHERA_ENGINE_AREADY_STARTED | Virtuoso is already started. | | PENTHERA_ENGINE_NO_BACKPLANE | Virtuoso started up, but couldn’t connect to the Cloud. | | PENTHERA_ENGINE_INVALID_OPTIONS | Wrong parameters | | PENTHERA_ENGINE_METHOD_IS_DEPRECATED | Error changing the user account. | | PENTHERA_ENGINE_INTERNAL_EXCEPTION | Virtuoso exception. | | PENTHERA_ENGINE_DATA_MIGRATION_ERROR | Error in the core data. | | PENTHERA_ENGINE_UNKNOWN_ERROR | Error |
Get download files
This method will return an array object with all the downloaded or pending to download assets with this json format:
[{
"assetID": "",
"isDownloaded": true,
"thumbnail": ""
}]
Get asset
This method will return the basic information of the asset, it requires an assetID to search within the database of the downloaded files, In case of success it will return a json object with this format:
{
"assetID": "",
"isDownloaded": true,
"thumbnail": "",
"streamURL": "",
"thumbnailTrack": "",
"subtitle": ""
}
Download asset
This method will add to the download quote an asset, it required:
assetID: unique content identifier title: title of the content streamURL: thumbnailURL: thumbnailTrackURL: subtitleURL:
It will return an success message or an error code
Play asset
This method will allow you to playback a downloaded content, just need to send the assetId as parameter and it will return a json object with asset information:
Delete asset
Delete a specific asset from the Penthera database, the assetID is required.
Delete all assets
Delete all the downloaded or pending to download assets in the Penthera database.
DRM
In case that the assets required DRM support, Penthera support the FairPlay playback offline, first we have to set the VirtuosoLicenseManager, this class will allow us to:
Configure the license and certificate
Manually induce the download of an offline license key for an asset,
Manually induce the refresh of a license key,
manually delete a license key from SDK management,
Provide a license key to the SDK for management which you acquired in a custom manner, and
Retrieve the managed license key for an asset, in case you need to manually provide it to a player in
Some custom manner rather than letting the SDK provide it during playback.
The VirtuosoLicenseManager instance has 2 functions to set the License and the certificate:
VirtuosoLicenseManager.downloadClientAppCertificate(fromURL: certificateURL, for: .vlm_FairPlay)
VirtuosoLicenseManager.setLicenseServerURL(licenseURL, for: .vlm_FairPlay)