# Androidの通知チャネルに対応する

## ヘッドアップ通知

[ヘッドアップ通知](https://developer.android.com/guide/topics/ui/notifiers/notifications?hl=ja)に対応させる場合、下記の設定が必要です。

### 1. Androidアプリ側の設定

ヘッドアップ通知はIMPORTANCE\_HIGHの通知チャネルとして設定する必要があるため、アプリ側で適切な設定が必要です。\
下記は通知チャネルの設定例です。

{% code overflow="wrap" %}

```java
NotificationChannel channel = new NotificationChannel("headsup_channel", "ヘッドアップチャンネル", NotificationManager.IMPORTANCE_HIGH);
channel.setDescription("ヘッドアップ通知のテストです");
channel.setShowBadge(true);
notificationManager.createNotificationChannel(channel);
```

{% endcode %}

### 2. KARTE管理画面側の設定

接客サービス作成画面より、プッシュのアクションを選択。

アクション編集画面の「チャンネルID(Android)」に、1で設定したchannel\_id(上記例では"headsup\_channel")を設定します。

※Messageの場合は[カスタムペイロード](https://support.karte.io/post/4n9tOwchpGsYzfEPviFYSR)として任意の値を設定してください。

![](/files/AwIZ6LGjzZy7S39zDgVN)

![](/files/5cU7yYBTyJ6wfgjAGp9T)

## 通知音や、ステータスバー表示を行わない通知

### 通知チャネルの設定

ヘッドアップ通知と同様の方法で、アプリ側で`IMPORTANCE_NONE`の通知チャネルを作成し、チャンネルIDに作成したIDを指定してください。

{% code overflow="wrap" %}

```java
NotificationChannel channel = new NotificationChannel("silent_channel", "サイレントチャンネル", NotificationManager.IMPORTANCE_NONE);
...
notificationManager.createNotificationChannel(channel);
```

{% endcode %}

通知チャネルの仕様については[公式ドキュメント](https://developer.android.com/develop/ui/views/notifications/channels?hl=ja)をご確認下さい。

またドキュメントに記載があるように、バッジ等の設定について追加で[バッジを無効にする](https://developer.android.com/develop/ui/views/notifications/badges?_gl=1*w0nhp8*_up*MQ..*_ga*MTQyNjgxOTQyMS4xNzEyODA5NTA2*_ga_6HH9YJMN9M*MTcxMjgwOTUwNS4xLjAuMTcxMjgwOTUwNS4wLjAuMA..\&hl=ja#disable) 設定が必要な場合もあります。

> すべての通知は、重要度に関係なく、システム UI の邪魔にならない場所（通知ドロワー内など）や、ランチャー アイコンにバッジとして表示されます。ただし、通知バッジの外観は変更できます。

### 受信時の処理

KARTE側から送信される通知については[Data Message](https://firebase.google.com/docs/cloud-messaging/concept-options?hl=ja#data_messages)の形式で送信されるため、通常は受信した通知は自動表示されません。\
ただし、アプリ側でKARTE SDKの[MessageHandler.handleMessage](https://plaidev.github.io/karte-sdk-docs/android/notifications/latest/notifications/io.karte.android.notifications/-message-handler/-companion/handle-message.html) 等の通知表示ロジックを実行している場合は通知が表示されるため、必要に応じて受信時の処理で表示を行わないような実装が必要になります。

参考: [通知の表示処理を実装する](https://app.developers.karte.io/app-send-notification/pages/d6eyaCZxuq0wnNmM4bE5#2-通知の表示処理を実装する)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://app.developers.karte.io/app-send-notification/android-heads-up-notification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
