FCM 푸시알림시 화면깨우기

2018. 7. 7. 17:28Android

반응형
1. AndroidManifest.xml

<uses-permission android:name="android.permission.WAKE_LOCK" />


2. PushUtils.class 

public class PushUtils {
    private static PowerManager.WakeLock mWakeLock;

    public static void acquireWakeLock(Context context){
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        mWakeLock = pm.newWakeLock(
                                    PowerManager.FULL_WAKE_LOCK |
                                    PowerManager.ACQUIRE_CAUSES_WAKEUP |
                                    PowerManager.ON_AFTER_RELEASE, "WAKEUP"
                                   );

        mWakeLock.acquire();
    }

    public static void releaseWakeLock(){
        if(mWakeLock != null){
            mWakeLock.release();
            mWakeLock = null;
        }
    }

}

3. MyFirebaseMessagingService.class

  - onCreate() 함수 override해서 PushUtils.acquireWakeLock(this); 

  - notification 관련 소스에서  PushUtils.releaseWakeLock();





 

https://smartstore.naver.com/byrollin? 

 

바이롤린 : 네이버쇼핑 스마트스토어

언제나 함께해요

smartstore.naver.com

 

반응형

'Android' 카테고리의 다른 글

Notification  (0) 2018.07.07
FCM 서버(Spring) 연동  (0) 2018.07.07
FCM(Firebase Cloud Messaging)  (0) 2018.07.06
개선된 로딩 화면 (Splash Screen)  (0) 2018.07.02
웹뷰(2)  (0) 2018.06.08