我创建了android应用程序,并通过firebase服务器向特定的人发送通知。请帮帮我。
My code is:
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG="MyMessageservice";
RemoteMessage remoteMessage;
@Override
public void onMessageReceived(RemoteMessage remoteMessage){
String title=remoteMessage.getNotification().getTitle();
String message=remoteMessage.getNotification().getBody();
String lick_action=remoteMessage.getNotification().getClickAction();
Intent intent=new Intent(click_action);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri notificattionSound= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(this);
notificationbuilder.setContentTitle(title);
notificationbuilder.setContentText(message);
notificationbuilder.setAutoCancel(true);
notificationbuilder.setSound(notificattionSound);
notificationbuilder.setSmallIcon(R.drawable.ic_launcher);
notificationbuilder.setContentIntent(pendingIntent);
notificationbuilder.setAutoCancel(true);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationbuilder.build());
}