2016-09-22 13 views
0

내가 내 안드로이드 인앱 NotificationComapt.Builder 속으로안드로이드 중포 기지 알림 푸시 알림 getSubText

public class NotificationMessagingService extends FirebaseMessagingService { 

    @Override 
    public void onMessageReceived(RemoteMessage remoteMessage) { 
     String title = remoteMessage.getNotification().getTitle(); 
     String message = remoteMessage.getNotification().getBody(); 

     Intent intent = new Intent(this, MainActivity.class); 
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
     PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); 

     NotificationCompat.Builder nb = new NotificationCompat.Builder(this); 
     nb.setContentTitle(title); 
     nb.setContentText(message); 
     nb.setSmallIcon(R.drawable.iconanotifica); 
     nb.setAutoCancel(true); 
     nb.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000}); 
     nb.setLights(Color.BLUE, 3000, 3000); 

     nb.setContentIntent(pendingIntent); 
     NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     notificationManager.notify(0, nb.build()); 
    } 
} 

에 통지를 관리하기 위해이 클래스를 사용,라는 방법이있다. 그래서 "remoteMessage.getNotification(). getSubText()"를 어떻게 얻습니까?

답변

0

NotificationCompat.Builder.setSubText()Android NotificationCompat reference documentation마다 알림 템플릿에 추가 텍스트 줄을 제공합니다. 장치에서 대형 형식 알림을 지원할 수 없으면 아무 효과가 없습니다.

remoteMessage.getNotification()은 Firebase Notification 콘솔 또는 Firebase Cloud Messaging 구현을 사용하는 앱 서버에서 보낸 메시지 중 notification payload을 받게됩니다.

는 알림 메시지에 추가 데이터 매개 변수를 추가 할 경우 다음 옵션을 사용하여 수행 할 수는 중포 기지 알림 콘솔에서

  1. 을에서 사용자 정의 데이터 키 - 값 쌍을 추가 고급 옵션 섹션.
  2. Firebase Cloud Messaging (FCM)을 사용하는 경우 messages with both notification and data payload을 보낼 수 있습니다.

사용 remoteMessage.getData()는, 특정 값을 검색하기 위해 클라이언트 응용 프로그램에서 메시지 get() 방법의 데이터 페이로드를 얻을 수 귀하의 통지에 서브 텍스트로 사용할 수 있습니다.

희망이 도움이됩니다.

+0

예, 작동합니다. 하지만 안드로이드 애플 리케이션을 사용하여 알림을 보내고 이것은 PHP 파일에 의해 관리됩니다. 데이터베이스에서 notifcation을 전송할 때만 하위 텍스트가 표시되지만 응용 프로그램에서 보내는 경우에는 표시되지 않습니다. 도울 수 있니? – Simone

+0

안녕하세요 @ 사이먼, 제발 좀 더 문제를 확장 해 주시겠습니까? 원본과 별개 인 경우 질문을 업데이트하거나 내 대답을 수락하고 새 스레드를 만드십시오. – weneedweeds

+0

아니요 제가 따라야 할 해결책이 아닙니다. 안드로이드 앱에서이 알림을 보내고 하위 텍스트를 설정해야합니다. – Simone