How to register the device for Notification hub after login.Xamarin.Android

I need to register the token after the user login in but once i launch the application for the first time the device register with an empty tag because the userid is empty

any suggestion please thank you.

MyFirebaseIIDService :

[IntentFilter(new[] { "" })]
public class MyFirebaseIIDService : FirebaseInstanceIdService
const string TAG = "MyFirebaseIIDService";
NotificationHub hub;

    public override void OnTokenRefresh()

        var refreshedToken = FirebaseInstanceId.Instance.Token;
        Log.Debug(TAG, "FCM token: " + refreshedToken);


    void SendRegistrationToServer(string token)
        Console.WriteLine("send register");
        // Register with Notification Hubs
        hub = new NotificationHub(Constants.NotificationHubName,
                                   Constants.ListenConnectionString, this);

        UserTag RequestTag = new UserTag();
        string UserId = RequestTag.UserId;
        Console.WriteLine(" USERID --> " + UserId);
        var tags = new List<string>() { UserId };

        var regID = hub.Register(token, tags.ToArray()).RegistrationId;

        Log.Debug(TAG, $"Successful registration of ID {regID}");

Sign In or Register to comment.