How to add Tags to "Push Notification" Azure notification Hub

Hi

I need to add tags, after the user has logged in. (AD groups as tags)

https://azure.microsoft.com/en-us/documentation/articles/xamarin-notification-hubs-push-notifications-android-gcm/

I know that there are many articles that discuss the same.

This is called when you install the App.

protected override void OnRegistered(Context context, string registrationId)
{
Log.Verbose(MyBroadcastReceiver.TAG, "GCM Registered: " + registrationId);
RegistrationID = registrationId;

createNotification("PushHandlerService-GCM Registered...",
                    "The device has been Registered!");

Hub = new NotificationHub(Constants.NotificationHubName, Constants.ListenConnectionString,
                            context);
try
{
    Hub.UnregisterAll(registrationId);
}
catch (Exception ex)
{
    Log.Error(MyBroadcastReceiver.TAG, ex.Message);
}

//var tags = new List<string>() { "falcons" }; // create tags if you want
var tags = new List<string>() {};

try
{
    var hubRegistration = Hub.Register(registrationId, tags.ToArray());
}
catch (Exception ex)
{
    Log.Error(MyBroadcastReceiver.TAG, ex.Message);
}

}

Of course I've tried to make a small public function that does the same, but the context, causes problems.

So it is possible to update this registration or do anything else.

Best regards Christian Lyck

Answers

Sign In or Register to comment.