How to control which notifications go to which clients?

GerryHGerryH USMember ✭✭✭
edited June 2018 in Xamarin.iOS

Is there some mechanism to determine which clients get which notifications? I have users that belong to groups, and each notification needs to go to a specific group.

After a couple days of getting familiar with iOS notifications (got the basics working), I have not come across much or actually anything on this topic. Is there a good resource somewhere? I have it working with tags on Android, but that doesn't seem to work for iOS; all clients still get all messages.

Also, sounds for notifications, they are mentioned, but... where is some sample code?


  • GerryHGerryH USMember ✭✭✭
    edited June 2018

    For the sound part, got it working:

          public override void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action<UNNotificationPresentationOptions> completionHandler)
             completionHandler(UNNotificationPresentationOptions.Alert | UNNotificationPresentationOptions.Sound); 

    and in the JSON, add
    at the same level as "alert".
    Found this stuff in discussion forums, not in documentation.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Which notification service are you using? Let's talk about Azure notification hubs for example. If you want to send notifications to a group of devices, categories may be helpful for you.
    This documentation illustrate the usage and the requirements of categories, you can refer to it for more details.

    Also we can do this configuration by ourselves if you use other libraries. After user registers the notification successfully, the device will receive a device in the event:

    public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
          Console.WriteLine("Registered for remote notifications");

    Then you can record this device token for a special group to your own server. When you send notifications from your sever, retrieve these device token and you can find the special devices you want to send.

  • GerryHGerryH USMember ✭✭✭
    edited June 2018

    thanks, I finally came across this:
    and found I had to use an expression (e.g. "A || B") to get it to work. The string array (e.g. ["A", "B"]) would not work for me.

Sign In or Register to comment.