Share via


Provisional notifications in Xamarin.iOS

Provisional notifications allow apps to deliver notifications without a user's explicit up-front consent. These notifications arrive quietly and show only in Notification Center, which lets users preview them before opting in or out of their continued delivery.

In Notification Center, users can specify that an app should stop delivering provisional notifications, continue delivering them provisionally, or start delivering them more prominently.

Sending provisional notifications

To send provisional notifications, provide UNAuthorizationOptions.Provisional as an option to the RequestAuthorization method of UNUserNotificationCenter:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    UNUserNotificationCenter center = UNUserNotificationCenter.Current;
    var options = UNAuthorizationOptions.Alert | UNAuthorizationOptions.Sound | UNAuthorizationOptions.Provisional;
    center.RequestAuthorization(options, (bool success, NSError error) => {
        // ...
    );
    return true;
}

If the user promotes provisional notifications to prominent delivery, the UNAuthorizationOptions values passed to RequestAuthorization will determine the new notification delivery settings (in the above code, UNAuthorizationOptions.Alert and UNAuthorizationOptions.Sound).