LoginSignup
5
3

More than 5 years have passed since last update.

iOS10のプッシュ通知でカスタムサウンドが鳴らない

Last updated at Posted at 2016-09-19

UserNotifications.frameworkを使ってプッシュ通知を実装しましたがカスタムサウンドが正しくならなくて困ったのでメモです。
通知ペイロードで指定したサウンドが再生されず、デフォルトの通知音が鳴ってしまう状態です。

結論としてはReleaseビルドすればちゃんと指定したサウンドがなりました。
なのでリリースすれば問題ないと思うのですが、ちょっと不安ですね。

Debugビルドだと音声ファイルが見つからないバグとかなんでしょうか・・・ (・・*)ゞ

使ったJSON(sound.mp3はCopy Bundle Resourcesに入ってます)

{
  "aps": {
    "alert": "message",
    "sound": "sound.mp3",
    "badge": 1
  }
}

一応optionsのとこでsoundを設定しています(デフォルト通知音はなっているのでここが問題じゃないと思いますが)。

UNUserNotificationCenter.current().requestAuthorization(options:  [.sound, .alert, .badge], completionHandler: { ・・・

再現環境

Xcode Version 8.0 (8A218a)
iPhone5S
iOS 10.0.1

5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3