Forum Xamarin Xamarin.Forms

Subscribing and Unsubscribing from notificiationhub with tags in xamarin

ClumpsypenguinClumpsypenguin Member
edited December 2019 in Xamarin.Forms

I am currently developing an App in Xamarin.Forms that recieves multiple notifications from notificiationhub for Android and UWP.

each notification has a tag that correspondent to a production line ID. My backend API has a hangfirejob that checks for the new entries in the database.

Recieving notifications is fine,but the users for the app do not need to recieve ALL notificiations.
Instead they can select in the app from which production line they want to see production stops.

Is there a way that i can select which notifications i want to recieve from a switch in Xamarin.Forms with these switches?

I tried to Unregister and register new tags each time the user made his selection, but the documentation of FCM state that you rarely have to unregister notificationschannel from an app. which also did not work with this code...

 public void ReRegisterToNotificationsHub(string token)
        {
            hub = new NotificationHub(AppSettingValues.NotificationHubName, AppSettingValues.ListenConnectionString, this);
            hub.UnregisterAll(token);
            var tags = GetLineValueKeysFromAppSetting();
            var register = hub.Register(token, tags);
            var regID = register.RegistrationId;
        }

Is there any other way that i can choose that i can filter the notifications to those that only has selected a line.
Can i dynamically reset my tags in a way without registering back or something?

Thanks in advance.

Best Answer

Answers

Sign In or Register to comment.