1 // Copyright © 2019 650 Industries. All rights reserved. 2 3 // swiftlint:disable type_name 4 5 import Foundation 6 import EXUpdates 7 import EXManifests 8 9 /** 10 LauncherSelectionPolicy similar to LauncherSelectionPolicyFilterAware but specifically for 11 Expo Go which uses a Expo-Go-specific field to determine compatibility. 12 */ 13 @objcMembers 14 public final class EXExpoGoLauncherSelectionPolicyFilterAware: NSObject, LauncherSelectionPolicy { 15 let sdkVersions: [String] 16 17 public init(sdkVersions: [String]) { 18 self.sdkVersions = sdkVersions 19 } 20 launchableUpdatenull21 public func launchableUpdate(fromUpdates updates: [Update], filters: [String: Any]?) -> Update? { 22 var runnableUpdate: Update? 23 for update in updates { 24 guard let updateSDKVersion = update.manifest.expoGoSDKVersion() else { 25 continue 26 } 27 28 if !sdkVersions.contains(updateSDKVersion) || !SelectionPolicies.doesUpdate(update, matchFilters: filters) { 29 continue 30 } 31 32 guard let runnableUpdateInner = runnableUpdate else { 33 runnableUpdate = update 34 continue 35 } 36 37 if runnableUpdateInner.commitTime.compare(update.commitTime) == .orderedAscending { 38 runnableUpdate = update 39 } 40 } 41 return runnableUpdate 42 } 43 } 44