fix: typo (complection -> completion)

This commit is contained in:
muxinqi 2021-11-19 13:14:40 +08:00 committed by Feng
parent 102a8f285d
commit 3fa407e565

View File

@ -89,19 +89,19 @@ class NotificationService: UNNotificationServiceExtension {
/// - Parameters:
/// - userInfo:
/// - bestAttemptContent: content
/// - complection:
fileprivate func downloadImage(_ imageUrl: String, complection: @escaping (_ imageFileUrl: String?) -> ()) {
/// - completion:
fileprivate func downloadImage(_ imageUrl: String, completion: @escaping (_ imageFileUrl: String?) -> ()) {
guard let groupUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.bark"),
let cache = try? ImageCache(name: "shared", cacheDirectoryURL: groupUrl),
let imageResource = URL(string: imageUrl)
else {
complection(nil)
completion(nil)
return
}
func downloadFinished() {
let cacheFileUrl = cache.cachePath(forKey: imageResource.cacheKey)
complection(cacheFileUrl)
completion(cacheFileUrl)
}
//
@ -113,7 +113,7 @@ class NotificationService: UNNotificationServiceExtension {
//
Kingfisher.ImageDownloader.default.downloadImage(with: imageResource, options: nil) { result in
guard let result = try? result.get() else {
complection(nil)
completion(nil)
return
}
//
@ -126,19 +126,19 @@ class NotificationService: UNNotificationServiceExtension {
///
/// - Parameters:
/// - bestAttemptContent: content
/// - complection:
/// - completion:
fileprivate func setImage(content bestAttemptContent: UNMutableNotificationContent,
complection: @escaping (_ content: UNMutableNotificationContent) -> ())
completion: @escaping (_ content: UNMutableNotificationContent) -> ())
{
let userInfo = bestAttemptContent.userInfo
guard let imageUrl = userInfo["image"] as? String else {
complection(bestAttemptContent)
completion(bestAttemptContent)
return
}
func finished(_ imageFileUrl: String?) {
guard let imageFileUrl = imageFileUrl else {
complection(bestAttemptContent)
completion(bestAttemptContent)
return
}
let copyDestUrl = URL(fileURLWithPath: imageFileUrl).appendingPathExtension(".tmp")
@ -155,29 +155,29 @@ class NotificationService: UNNotificationServiceExtension {
) {
bestAttemptContent.attachments = [attachment]
}
complection(bestAttemptContent)
completion(bestAttemptContent)
}
downloadImage(imageUrl, complection: finished)
downloadImage(imageUrl, completion: finished)
}
/// icon
/// - Parameters:
/// - bestAttemptContent: content
/// - complection:
/// - completion:
fileprivate func setIcon(content bestAttemptContent: UNMutableNotificationContent,
complection: @escaping (_ content: UNMutableNotificationContent) -> ())
completion: @escaping (_ content: UNMutableNotificationContent) -> ())
{
if #available(iOSApplicationExtension 15.0, *) {
let userInfo = bestAttemptContent.userInfo
guard let imageUrl = userInfo["icon"] as? String else {
complection(bestAttemptContent)
completion(bestAttemptContent)
return
}
func finished(_ imageFileUrl: String?) {
guard let imageFileUrl = imageFileUrl else {
complection(bestAttemptContent)
completion(bestAttemptContent)
return
}
var personNameComponents = PersonNameComponents()
@ -225,19 +225,19 @@ class NotificationService: UNNotificationServiceExtension {
do {
let content = try bestAttemptContent.updating(from: intent) as! UNMutableNotificationContent
complection(content)
completion(content)
}
catch {
// Handle error
}
complection(bestAttemptContent)
completion(bestAttemptContent)
}
downloadImage(imageUrl, complection: finished)
downloadImage(imageUrl, completion: finished)
}
else {
complection(bestAttemptContent)
completion(bestAttemptContent)
}
}