Unsubscribing or Unregistering from Azure Mobile Service Push Notifications from Xamarin iOS
Wow, that’s a long title. I didn’t know how to find it in Google when I was searching for terms similar to that earlier, so hopefully this post helps. So you’ve gone ahead and added push notifications to your Xamarin app using Azure Mobile Services. There are tons of tutorials out there to show you how to do it. The next logical step (if you love your users) is to add a setting someplace to allow users to turn off their push notifications. So then you go looking for good documents on how to update the tags that you subscribed to… and if they’re out there, they’re really hard to find. Here’s the quick and easy recipe: do the exact same thing as the initial registration, but with an empty (or updated) list of tags.
Setting this up with the boilerplate declaration:
var push = new MobileServiceClient(url,key).GetPush();
So to register one tag:
push.RegisterNativeAsync(deviceToken, new List<string>() { “tagname” });
And to unregister:
push.RegisterNativeAsync(deviceToken, new List<string>());
Comments
Comments are closed