Skip to content

Commit

Permalink
添加默认响铃
Browse files Browse the repository at this point in the history
  • Loading branch information
Finb committed Jul 26, 2024
1 parent 78f2c8a commit f588f83
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions NotificationServiceExtension/Processor/CallProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@ class CallProcessor: NotificationContentProcessor {
self.startAudioWorkCompletion = completion

let sound = ((content.userInfo["aps"] as? [String: Any])?["sound"] as? String)?.split(separator: ".")
let soundName = sound?.first ?? "multiwayinvitation"
let soundType = sound?.last ?? "caf"
let soundName: String
let soundType: String
if sound?.count == 2, let first = sound?.first, let last = sound?.last {
soundName = String(first)
soundType = String(last)
} else {
soundName = "multiwayinvitation"
soundType = "caf"
}

// 先找自定义上传的铃声,再找内置铃声
guard let audioPath = getSoundInCustomSoundsDirectory(soundName: "\(soundName).\(soundType)") ??
Bundle.main.path(forResource: String(soundName), ofType: String(soundType))
Bundle.main.path(forResource: soundName, ofType: soundType)
else {
completion()
return
Expand Down

0 comments on commit f588f83

Please sign in to comment.