-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Describe user-agent header configuration
- Loading branch information
Artem Yelizarov
committed
Jun 11, 2024
1 parent
d172c44
commit d637e14
Showing
3 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Sources/PlaybackSDK/Documentation.docc/Resources/PlayBackDemoAppWithUserAgent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import SwiftUI | ||
import PlaybackSDK | ||
import Alamofire | ||
|
||
@main | ||
struct PlayBackDemoApp: App { | ||
|
||
let sdkManager = PlayBackSDKManager() | ||
let apiKey = "API_KEY" | ||
var body: some Scene { | ||
WindowGroup { | ||
HomeView() | ||
} | ||
} | ||
|
||
init() { | ||
// Get the user-agent set by Alamofire | ||
let userAgent = AF.session.configuration.httpAdditionalHeaders?["User-Agent"] | ||
|
||
// Initialize the Playback SDK with the provided API key and custom user-agent | ||
PlayBackSDKManager.shared.initialize(apiKey: apiKey, userAgent: userAgent) { result in | ||
switch result { | ||
case .success(let license): | ||
// Obtained license upon successful initialization | ||
print("SDK initialized with license: \(license)") | ||
|
||
// Register the video player plugin | ||
let bitmovinPlugin = BitmovinPlayerPlugin() | ||
VideoPlayerPluginManager.shared.registerPlugin(bitmovinPlugin) | ||
|
||
case .failure(let error): | ||
// Print an error message and set initializationError flag upon initialization failure | ||
print("SDK initialization failed with error: \(error)") | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters