관리 메뉴

웹개발자의 기지개

[안드로이드] 구글 Firebase Push 알림 최신 기능 업데이트 - Android 12 이상시 Push 안되는 현상 해결법 본문

안드로이드

[안드로이드] 구글 Firebase Push 알림 최신 기능 업데이트 - Android 12 이상시 Push 안되는 현상 해결법

http://portfolio.wonpaper.net 2023. 1. 9. 16:22

기존에 잘가는 구글파이어베이스 Push 알림이 최근 폰에서는 갑자기 안되는 현상이 발생했다.

 

적용되는 안드로이드 버전은 12이상이다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
        Intent intent;
        PendingIntent pendingIntent;
 
        intent = new Intent(this, MainActivity.class);
        Bundle bundle = new Bundle();
        bundle.putString("url", linkUrl);   //push 정보중 url 값을 MainActivity로 넘김
        intent.putExtras(bundle);
 
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
 
        // 최신 안드로이드 12이상은 푸시가 오도록 수정
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
            pendingIntent = PendingIntent.getActivity
                    (this0, intent, PendingIntent.FLAG_MUTABLE);
        }
        else
        {
            pendingIntent = PendingIntent.getActivity
                    (this0, intent, PendingIntent. FLAG_UPDATE_CURRENT);
        }
cs

 

12라인부터 이다.

 

참고 : https://stackoverflow.com/questions/72816718/android-notification-issue-after-last-android-update-pushy-me-api

참고 : https://stackoverflow.com/questions/74733208/notification-builder-action-not-working-on-api-31-android-12

Comments