Как отправить токен firebase на сервер бэкенда из android studio - PullRequest
0 голосов
/ 20 апреля 2020

У меня есть реагирующее веб-приложение, и я использую его как мобильное приложение и для уведомлений pu sh. Я использую firebase и добился этого с помощью консоли firebase, и я хочу отправлять уведомления с внутреннего сервера, но я новичок ie в студии android, поэтому я не могу выяснить, как отправить токен firebase на внутренний сервер в частном API-интерфейсе call.my. Данные пользователя находятся в избыточном хранилище, и мне нужно сделать личный запрос API-записи в моем файле FirebaseMessagingService. любая помощь будет принята с благодарностью.

ниже мой код из файла FirebaseMessagingService

package com.example.goldfish;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;

public class MyMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        showNotification(remoteMessage.getNotification().getTitle(), remoteMessage.getNotification().getBody());
    }
    public void showNotification(String title, String message){
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "MyNotifications")
                .setContentTitle(title)
                .setSmallIcon(R.drawable.ic_launcher_background)
                .setAutoCancel(true)
                .setContentText(message);
        NotificationManagerCompat manager = NotificationManagerCompat.from(this);
        manager.notify(999, builder.build());
    }
}

...