在我的应用中继续从FCM获取旧通知

时间:2018-02-07 07:32:34

标签: android firebase firebase-cloud-messaging

我正在使用FCM在我的Android应用中发送下载文件的通知。当我的应用程序没有运行并且我发送FCM然后我收到我之前发送的所有通知和新的连续通知。 怎么克服这个? 这是我的MyFirebaseMessagingService类。

    public class MyFirebaseMessagingService extends FirebaseMessagingService {
        @Override
            public void onMessageReceived(RemoteMessage remoteMessage) {
                Log.d("data", "onMessageReceived: firebase called");                 
                Map<String, String> data = remoteMessage.getData();                   
                String url = data.get("file_url");            
                Intent broadcast_intent = new Intent();
                broadcast_intent.putExtra(MainActivity.FIREBASE_URL, url);                    broadcast_intent.setAction(MainActivity.FIREBASE_URL_BROADCAST);
                sendBroadcast(broadcast_intent);            
            }

public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    private static final String TAG = "MyFirebaseIIDService";                  
    @Override
    public void onTokenRefresh() {

        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);


        sendRegistrationToServer(refreshedToken);
    }

    private void sendRegistrationToServer(String token) {

    }

0 个答案:

没有答案