코딩쟁이/android
[안드로이드]FCM 푸시울릴때 화면깨우기.
깜둥사자
2019. 10. 8. 17:57
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be: https://goo.gl/39bRNJ
Log.d(TAG, "From: " + remoteMessage.getFrom());
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
HashMap hash_map=new HashMap();
hash_map.putAll(remoteMessage.getData());
// sendNotification(context,remoteMessage.getData());
PushNotificationManager ntify=new PushNotificationManager(getBaseContext(),hash_map);
//푸시울렸을때 화면깨우기.
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE );
@SuppressLint("InvalidWakeLockTag")
PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG" );
wakeLock.acquire(3000);
if (/* Check if data needs to be processed by long running job */ true) {
// For long-running tasks (10 seconds or more) use Firebase Job Dispatcher.
scheduleJob();
} else {
// Handle message within 10 seconds
handleNow();
}
}
반응형