UNMutableNotificationContentにて実装したローカル通知のsoundについて質問です。
以下の情報より、形式はLinear PCM、MA4 (IMA/ADPCM)、µLaw、aLawのいずれかで、長さは30秒以内と解釈しました。
https://developer.apple.com/documentation/usernotifications/unnotificationsound?language=objc
質問は2点です。
4つの形式に入っていないmp3でも問題なく再生されるのですが、mp3で制作を進めても問題ないでしょうか。
(ボイス再生アプリを作っており、音源の数が多いため、一つ一つの音源のサイズを小さくしたいためです)
音源の長さが10秒程度でも、再生時には5〜6秒で切られてしまいます。30秒以内であれば全て再生されると解釈したのですが、これは仕様でしょうか。
(30秒を超える音源を指定するとデフォルトの通知音が再生されます)
Swift
1import UIKit 2import UserNotifications 3 4class ViewController: UIViewController { 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 9 let center = UNUserNotificationCenter.current() 10 center.requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in 11 if granted { 12 } else { 13 } 14 } 15 16 let content = UNMutableNotificationContent() 17 content.title = "Title" 18 content.subtitle = "Subtitle" 19 content.body = "Body" 20 content.sound = UNNotificationSound.init(named: UNNotificationSoundName(rawValue: "1.mp3")) 21 22 let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false) 23 let request = UNNotificationRequest(identifier: "FiveSecond", content: content, trigger: trigger) 24 25 UNUserNotificationCenter.current().add(request, withCompletionHandler: nil) 26 } 27 28}
環境は以下です。
iOS12.1.2、Xcode10.1、Swift4.2.1
何卒よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/05 07:00