Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 2.5 KB

File metadata and controls

53 lines (45 loc) · 2.5 KB
title description ms.service ms.assetid ms.subservice author ms.author ms.date no-loc
Provisional notifications in Xamarin.iOS
This document describes how to use Xamarin.iOS to work with provisional notifications. Provisional notifications, introduced in iOS 12, allow applications to send quiet notifications without explicit user permission.
xamarin
5DCB36B9-2637-48AE-8FC0-F6124F08AC48
xamarin-ios
davidortinau
daortin
09/04/2018
Objective-C

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).

Related links