|
|
|
|
@ -10,6 +10,7 @@ import CoreData |
|
|
|
|
import BackgroundTasks |
|
|
|
|
import AVFoundation |
|
|
|
|
import Combine |
|
|
|
|
import CloudKit |
|
|
|
|
|
|
|
|
|
@main |
|
|
|
|
struct LeCountdownApp: App { |
|
|
|
|
@ -79,6 +80,8 @@ struct LeCountdownApp: App { |
|
|
|
|
Logger.log("preferredLanguages = \(String(describing: Locale.preferredLanguages))") |
|
|
|
|
|
|
|
|
|
self._patch() |
|
|
|
|
let containerAvailable = self.isICloudContainerAvailable() |
|
|
|
|
Logger.log("isICloudContainerAvailable = \(containerAvailable)") |
|
|
|
|
|
|
|
|
|
// let voices = AVSpeechSynthesisVoice.speechVoices() |
|
|
|
|
// let grouped = Dictionary(grouping: voices, by: { $0.language }) |
|
|
|
|
@ -115,7 +118,6 @@ struct LeCountdownApp: App { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _patch() { |
|
|
|
|
|
|
|
|
|
let context = PersistenceController.shared.container.viewContext |
|
|
|
|
@ -131,4 +133,37 @@ struct LeCountdownApp: App { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func isICloudContainerAvailable() -> Bool { |
|
|
|
|
print(#function) |
|
|
|
|
CKContainer.default().accountStatus { (accountStatus, error) in |
|
|
|
|
|
|
|
|
|
if accountStatus == .available { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// |
|
|
|
|
// Checking account availability |
|
|
|
|
// Silently return if everything goes well, or do a second check 200ms after the first failure |
|
|
|
|
// |
|
|
|
|
|
|
|
|
|
DispatchQueue.global().asyncAfter(deadline: .now() + 0.2) { |
|
|
|
|
|
|
|
|
|
guard error != nil, accountStatus != CKAccountStatus.available else {return} |
|
|
|
|
|
|
|
|
|
print("iCloud account is not available! Be sure you have signed in iCloud on this device!") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if FileManager.default.ubiquityIdentityToken != nil { |
|
|
|
|
//print("User logged in") |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
//print("User is not logged in") |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|