Forum Xamarin Xamarin.iOS

Conditional Push Notifications for iOS

CodeSenseiCodeSensei USMember ✭✭

I want to be able to send push notifications based on the app's settings. The setting is to either show or not show the notification. The user can change the setting anytime.

  • I tried Service Extension, but couldnt find a way to suppress the notification when the setting is to not show.
  • I tried sending a silent notification and then created a local notification if I need to show. This works, but silent notifications are unreliable.

As last resort, I can send settings to backend server, but dont want to keep system of records for every subscriber. And do not want to get in the business of writing my own APN provider.


  • LandLuLandLu Member, Xamarin Team Xamurai

    You can try to register tags for sending remote notifications to the specific devices. Divide the user devices to two groups(one can receive the notification, another not). I use AZure to express this for instance:

    PnsHandler = ((AppDelegate)UIApplication.SharedApplication.Delegate).DeviceToken;
    // Resign all firstly
    hub.UnregisterAllAsync(PnsHandler, (error) => {
        if (error != null)
            Console.WriteLine("Error calling Unregister: {0}", error.ToString());
        hub.RegisterNativeAsync(PnsHandler, tags, (errorCallback) => {
            if (errorCallback != null)
                Console.WriteLine("RegisterNativeAsync error: " + errorCallback.ToString());

    When user modifies the settings, use the code above to add tags. Then send notifications to one tag and another group will not receive this notification. This achieve the effect that some of the users show the notification and some of users not.

Sign In or Register to comment.