Skip to content

Commit

Permalink
Add tvOS 13 to if available checks in Presentation Manager (ArtSabint…
Browse files Browse the repository at this point in the history
…sev#360)

* Add tvOS 13 to if available checks

* Add queryItem for tvOS App Store

* Move inline tvOS Query parameter strings to Constants struct
  • Loading branch information
frydiggity authored Jan 17, 2021
1 parent 3197a6d commit 380f790
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Sources/Managers/APIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public struct APIManager {
static let bundleID = "bundleId"
/// Constant for the `country` parameter in the iTunes Lookup API request.
static let country = "country"
/// Constant for the `entity` parameter in the iTunes Lookup API reqeust.
static let entity = "entity"
/// Constant for the `entity` parameter value when performing a tvOS iTunes Lookup API reqeust.
static let tvSoftware = "tvSoftware"
}

/// Return results or errors obtained from performing a version check with Siren.
Expand Down Expand Up @@ -114,6 +118,11 @@ extension APIManager {

var items: [URLQueryItem] = [URLQueryItem(name: Constants.bundleID, value: Bundle.main.bundleIdentifier)]

#if os(tvOS)
let tvOSQueryItem = URLQueryItem(name: Constants.entity, value: Constants.tvSoftware)
items.append(tvOSQueryItem)
#endif

if let countryCode = country.code {
let item = URLQueryItem(name: Constants.country, value: countryCode)
items.append(item)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Managers/PresentationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private extension PresentationManager {
private extension PresentationManager {
private func createWindow() -> UIWindow? {
var window = UIWindow()
if #available(iOS 13.0, *) {
if #available(iOS 13.0, tvOS 13.0, *) {
guard let windowScene = getFirstForegroundScene() else { return nil }
window = UIWindow(windowScene: windowScene)
} else {
Expand All @@ -243,7 +243,7 @@ private extension PresentationManager {
return window
}

@available(iOS 13.0, *)
@available(iOS 13.0, tvOS 13.0, *)
private func getFirstForegroundScene() -> UIWindowScene? {
let connectedScenes = UIApplication.shared.connectedScenes
if let windowActiveScene = connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
Expand Down

0 comments on commit 380f790

Please sign in to comment.