Код: Выделить всё
[Service(Exported = true)]
[IntentFilter(new[] { "com.google.firebase.MESSAGING_EVENT" })]
public class MyFirebaseMessagingService : FirebaseMessagingService
{
const string TAG = "MyFirebaseMessagingService";
NotificationHub hub;
public override void OnNewToken(string p0)
{
base.OnNewToken(p0);
SendRegistrationToServer(p0);
}
private void SendRegistrationToServer(string token)
{
// Register with Notification Hubs
hub = new NotificationHub(Helpers.ApiKeys.NotificationHubName, Helpers.ApiKeys.ListenConnectionString, this);
try
{
hub.UnregisterAll(token);
}
catch (Exception ex)
{
Log.Error(TAG, ex.Message);
}
var tags = new List() { Entities.Settings.DeviceId };
var regID = hub.Register(token, tags.ToArray()).RegistrationId;
Log.Debug(TAG, $"Successful registration of ID {regID}");
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... android-to