> For the complete documentation index, see [llms.txt](https://developers.fingerpush.com/app-push/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.fingerpush.com/app-push/sdk-manual/android/unsubscribe.md).

# Android 푸시 알림 원클릭 수신거부 구현 가이드

안녕하세요, 핑거푸시 기술지원팀입니다.

광고성 정보가 포함된 푸시 메시지 발송 시, 사용자가 노티피케이션 센터에서 앱을 열지 않고도 즉시 수신거부를 할 수 있는 '원클릭 수신거부' 기능 구현 가이드를 안내해 드립니다.

핑거푸시에서 광고성 메시지 옵션을 On으로 설정하여 발송할 경우, Payload에 추가되는 data.fpCategory 값을 활용하여 다음과 같이 구현하실 수 있습니다.

## **1. 데이터 구조 및 구분 값 (payload)**

메시지 수신 시 전달되는 data.fpCategory 항목을 통해 광고성 여부를 판단합니다.

<table data-header-hidden><thead><tr><th width="149.71484375" valign="top"></th><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">구분</td><td valign="top">비고</td><td valign="top">data.fpCategory 값</td></tr><tr><td valign="top">광고성 메시지</td><td valign="top">노티피케이션 내 '수신거부' 버튼 노출 대상</td><td valign="top">"fp1"</td></tr><tr><td valign="top">일반 메시지</td><td valign="top">일반 알림으로 표시</td><td valign="top">"fp0"</td></tr></tbody></table>

## **2. Android 구현 단계**

**단계 1: 데이터 수신 및 광고 여부 확인**

FirebaseMessagingService의 onMessageReceived에서 전달받은 데이터 중 fpCategory가 "fp1"인지 확인합니다.

```
//java
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    if (remoteMessage.getData().size() > 0) {
        String fpCategory = remoteMessage.getData().get(“data.fpCategory");
        String title = remoteMessage.getData().get(“data.title");
        String message = remoteMessage.getData().get(“data.message");

        // fpCategory가 "fp1"인 경우 수신거부 버튼이 포함된 알림 생성
        sendNotification(title, message, "fp1".equals(data.fpCategory));
    }
}
```

**단계 2: 알림 내 '수신거부' 버튼 추가 (addAction)**

NotificationCompat.Builder를 사용하여 알림을 생성할 때, 광고성 메시지라면 수신거부 액션을 추가합니다.

<pre><code>//java
private void sendNotification(String title, String message, boolean isAd) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this, “채널아이디 입력”)
            .setSmallIcon(R.drawable.ic_notification)
            .setContentTitle(title)
            .setContentText(message)
            .setAutoCancel(true);

    if (isAd) {
        // 클릭 시 UnsubscribeReceiver로 전달될 Intent 구성
        Intent cancelIntent = new Intent(this, UnsubscribeReceiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(
                this, 0, cancelIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
<strong>        );
</strong>
        // 알림에 '수신거부' 버튼 추가
        builder.addAction(R.drawable.ic_block, "수신거부", pendingIntent);
    }

    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(1001, builder.build());
}
</code></pre>

**단계 3: 핑거푸시 SDK API를 통한 수신거부 처리**

사용자가 알림의 버튼을 클릭하면 BroadcastReceiver에서 핑거푸시 SDK의 setAdvertisePushEnable API를 호출하여 광고 수신 동의를 거부(false) 처리합니다.

```
//java
public class UnsubscribeReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // 핑거푸시 광고수신 설정 API 호출 (거부 처리)
        FingerPushManager.getInstance(this). setAdvertisePushEnable(false, new ObjectListener() {       
        @Override
        public void onComplete(String code, String message, JSONObject data) {
                 // 광고성 알림 수신이 거부되었습니다."                    
                // 처리 완료 후 알림 센터에서 해당 알림 제거
        });
    }
}
```

## **3. 수신거부 버튼 노출 예시 이미지**

<figure><img src="/files/JrvKSHnFXTjOQ744Tb9G" alt=""><figcaption></figcaption></figure>

**※ 핑거푸시 SDK에서 제공하는 FingerNotification 클래스는 표준화된 알림 생성 기능을 제공하므로, '수신거부'와 같은 커스텀 액션 버튼을 추가하는 기능을 지원하지 않습니다. (추후 지원예정)**

**FingerNotification 호출을 생략하고, NotificationCompat.Builder를 사용하여 알림을 직접 구성합니다.**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers.fingerpush.com/app-push/sdk-manual/android/unsubscribe.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
