마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

FCM PUSH MESSAGE 문제가 좀 있습니다...

0 추천

fcm 을 이용하여 푸시 메세지 보내는 연습중입니다.

위 스샷에 보이듯이...메세지는 안 오고...타이틀만 옵니다..

메세지는 구글 사이트에서 보내고 있구요..아직 서버가 마련되지 않아서요..

다음은 소스입니다.

public class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {

    private static final String TAG = "FirebaseMsgService";

    // [START receive_message]
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {

        //추가한것
        sendNotification(remoteMessage.getData().get("message"));
    }

    private void sendNotification(String messageBody) {
        Log.e("KSJ", "Received message : " + messageBody);
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);

        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))
                .setContentTitle("FCM Push Test by ksj")
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setLights(000000255, 500, 2000)
                .setContentIntent(pendingIntent);

        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        PowerManager pm = (PowerManager)this.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "KSJ");
        wakeLock.acquire(5000);

        notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }

}

 

 

푸시 메세지는 이번이 첨이라 뭐가 문제인지 잘 모르겠어서..

이렇게 질문을 드립니다.

카톡같은 경우에는 메세지까지 다 보이잖아여.. 그런걸 원합니다....간절하게..

 

 

 

 

 

 

앤드류이드 (6,190 포인트) 님이 2016년 9월 7일 질문

1개의 답변

0 추천
 
채택된 답변
remoteMessage.getNotification().getBody() 로 해보세요.

fcm 콘솔에서 보내는 메세지는 body에 실어서 보내주는거 같더군요.

 

물론 추후에 서버 구현 하신다면 서버에서도 body에 실을것인지 data에 실을것인지 설정이 가능 합니다.
Development Guy (70,570 포인트) 님이 2016년 9월 8일 답변
앤드류이드님이 2016년 9월 8일 채택됨
완전 감사합니다..^^
...