Android – private void sendregistrationtoserver (string token) parameter token is never used

I've tried all the available answers, but it doesn't help. What did I miss here?

private void sendRegistrationToServer(String token)`{
}

resolvent:

As mentioned in the comments, the question is vague, but I kind of get what you ask

Sendregistrationtoserver() is an optional method, which can be seen in most examples of firebase. Start with GitHub example:

package com.google.firebase.quickstart.fcm;

import android.util.Log;

import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.FirebaseInstanceIdService;


public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {

    private static final String TAG = "MyFirebaseIIDService";

    /**
     * Called if InstanceID token is updated. This may occur if the security of
     * the prevIoUs token had been compromised. Note that this is called when the InstanceID token
     * is initially generated so this is where you would retrieve the token.
     */
    // [START refresh_token]
    @Override
    public void onTokenRefresh() {
        // Get updated InstanceID token.
        String refreshedToken = FirebaseInstanceId.getInstance().getToken();
        Log.d(TAG, "Refreshed token: " + refreshedToken);

        // If you want to send messages to this application instance or
        // manage this apps subscriptions on the server side, send the
        // Instance ID token to your app server.
        sendRegistrationToServer(refreshedToken);
    }
    // [END refresh_token]

    /**
     * Persist token to third-party servers.
     *
     * Modify this method to associate the user's FCM InstanceID token with any server-side account
     * maintained by your application.
     *
     * @param token The new token.
     */
    private void sendRegistrationToServer(String token) {
        // TODO: Implement this method to send token to your app server.
    }
}

From here, you can see that sendregistrationtoserver() is called inside ontokenrefresh(), which generates a registration token for FCM. The code document has told sendregistrationtoserver() what should happen:

Sending the registration token to your own app server is optional, but it is strongly recommended (see FCM DOCS). This way, you can have the token for future use

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>