Safely unwrap API Version in case MARKETING_VERSION is missing (IOS-262)

This commit is contained in:
Marcus Kida 2024-07-18 11:53:00 +02:00
parent 27c6c58d96
commit 4d2bdaf219
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@ public final class APIService {
public init(backgroundManagedObjectContext: NSManagedObjectContext) {
self.backgroundManagedObjectContext = backgroundManagedObjectContext
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "Unknown"
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = ["User-Agent" : "mastodon-ios/" + appVersion]
self.session = URLSession(configuration: configuration)