package com.swiftcleaner.chovey.model.service;

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

public class MyFirebaseMessagingService extends FirebaseMessagingService {
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        // 处理收到的消息
        if (remoteMessage.getNotification() != null) {
            String title = remoteMessage.getNotification().getTitle();
            String body = remoteMessage.getNotification().getBody();
            sendNotification(title, body);
        }
    }

    private void sendNotification(String title, String body) {
        // 这里实现通知的发送逻辑
    }

    @Override
    public void onNewToken(String token) {
        // 每当生成新的令牌时调用
        sendRegistrationToServer(token);
    }

    private void sendRegistrationToServer(String token) {
        // 将令牌发送到你的服务器
    }
}