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

  • リリースバージョン: Washingtondc
  • 更新日 2024年03月04日
  • 読む4読むのに数分
  • プッシュ通知にサウンドとトーンを追加して、メッセージが緊急であるか、ユーザーの注意が必要な場合かをユーザーに示します。

    プッシュ通知に音を追加するための JSON の例

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

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

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

    音を含む重要なアラートの JSON の例

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

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

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

      指定できる値は表のとおりです。
      注:
      トーンごとに、接尾辞 「-Short」を追加してリングの長さを短くするオプションがあります。NotificationAlert-5.ca を除くすべてのトーンを短縮できます。
      受け入れられるファイル名の値 トーンリズム
      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 劇的