プッシュ通知のサウンドの構成

  • リリースバージョン: Yokohama
  • 更新日 2025年01月30日
  • 所要時間:4分
  • プッシュ通知にサウンドとトーンを追加して、メッセージが緊急であるか、ユーザーの注意が必要なだけであるかをユーザーに示します。

    プッシュ通知にサウンドを追加する JSON の例

    次の JSON は、プッシュ通知にトーンを追加する方法の例です。この例で使用されているトーンの名前は NotificationAlert-2" です。
    json["aps"]["sound"] = "NotificationAlert-2.caf";

    このトピックの最後にある表には、使用可能なすべてのトーンが一覧表示されます。各サウンドのトーンを聞くには、ターゲット サウンド パラメーターを使用して通知を構成する必要があります。

    注:
    トーンごとに、接尾辞 -Shortを追加してリングの長さを短くするオプションがあります。NotificationAlert-5.caf を除くすべてのトーンを短縮できます。

    サウンドを含む重要なアラートの JSON の例

    次の JSON は、重要なアラートのサウンドパラメーターの定義方法の例です。重大なアラートの詳細については、「 モバイルの重要なアラート」を参照してください。

    json["aps"]["sound"] = { 
              "critical": 1, 
              "name": "NotificationAlert-3-Short.caf", 
              "volume": 1.0 
          }; 
    
    サンプルの JSON コード内のパラメーターは、次のとおりです。
    • critical パラメーターは、通知を重大なアラートとして定義します。1 は重大アラートがアクティブであることを意味し、0 は重大アラートが非アクティブであることを意味します。
    • volume パラメーターは、通知音の音量を定義します。範囲は、最も小さい 0.1 から最も大きい 1.0 までです。
    • name パラメーターは、プッシュ通知が送信されたときにアクティブになるトーンの名前です。重要なアラートの場合は、劇的なトーンでユーザーのリズムを考慮します。
      注:
      name値が定義されていない場合、システムはアプリケーションのデフォルトの着信音を使用します。アプリケーションに着信音が定義されていない場合、システムはデバイスのデフォルトの着信音を使用します。

      各サウンドのトーンを聞くには、ターゲット サウンド パラメーターを使用して通知を構成する必要があります。

      許容値を表に示します。
      注:
      トーンごとに、接尾辞 -Shortを追加してリングの長さを短くするオプションがあります。NotificationAlert-5.caf を除くすべてのトーンを短縮できます。
      承認されるファイル名の値 トーンリズム
      NotificationAlert-1.caf まろやかで、リラックスし、ゆっくりと
      NotificationAlert-1-Short.caf まろやかで、リラックスし、ゆっくりと
      NotificationAlert-2.caf 劇的
      NotificationAlert-2-Short.caf 劇的
      NotificationAlert-3.caf 劇的
      NotificationAlert-3-Short.caf 劇的
      NotificationAlert-4.caf まろやかで、リラックスし、ゆっくりと
      NotificationAlert-4-Short.caf まろやかで、リラックスし、ゆっくりと
      NotificationAlert-5.caf まろやかで、リラックスし、ゆっくりと
      NotificationAlert-6.caf お祝い、ハッピー
      NotificationAlert-6-Short.caf お祝い、ハッピー
      NotificationAlert-7.caf お祝い、ハッピー
      NotificationAlert-7-Short.caf お祝い、ハッピー
      NotificationAlert-8.caf お祝い、ハッピー
      NotificationAlert-8-Short.caf お祝い、ハッピー
      NotificationAlert-9.caf ドラマチックでパワフル
      NotificationAlert-9-Short.caf ドラマチックでパワフル
      NotificationAlert-10.caf ドラマチック、サスペンスフル
      NotificationAlert-10-Short.caf ドラマチック、サスペンスフル
      NotificationAlert-11.caf 劇的
      NotificationAlert-11-Short.caf 劇的
      NotificationAlert-12.caf 劇的
      NotificationAlert-12-Short.caf 劇的
      NotificationAlert-13.caf 劇的
      NotificationAlert-13-Short.caf 劇的
      NotificationAlert-14.caf 劇的
      NotificationAlert-14-Short.caf 劇的
    注:
    名前の値が定義されていない場合、システムはアプリケーションのデフォルトの着信音を使用します。アプリケーションに着信音が定義されていない場合、システムはデバイスのデフォルトの着信音を使用します。