iOS Guides | Samples

MonoTouch.UIKit.UIUserNotificationSettings Class

Permissions for local notifications, as controlled by the application user.

See Also: UIUserNotificationSettings

Syntax

[MonoTouch.Foundation.Register("UIUserNotificationSettings", true)]
[MonoTouch.ObjCRuntime.Deprecated(MonoTouch.ObjCRuntime.PlatformName.iOS, 10, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, "Use 'UserNotifications.UNNotificationSettings' instead.")]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 8, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.WatchOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
[MonoTouch.ObjCRuntime.Unavailable(MonoTouch.ObjCRuntime.PlatformName.TvOS, MonoTouch.ObjCRuntime.PlatformArchitecture.All, null)]
public class UIUserNotificationSettings : NSObject, INSCopying, INSSecureCoding, IDisposable

Remarks

Starting with iOS 8, users must give explicit permission for apps that wish to respond to local notifications.

Prior to attempting to send local notifications, devs must request permission from the application user to manipulate the app icon badge, play a sound, or display an alert (see UIUserNotificationType). Typically, this is done in the UIAppDelegate.FinishedLaunching overridden method:

F# Example

UIUserNotificationSettings.GetSettingsForTypes(
    UIUserNotificationType.Alert 
    ||| UIUserNotificationType.Badge 
    ||| UIUserNotificationType.Sound, 
new NSSet())
|> UIApplication.SharedApplication.RegisterUserNotificationSettings

C# Example

var settings = UIUserNotificationSettings.GetSettingsForTypes(
    UIUserNotificationType.Alert 
    | UIUserNotificationType.Badge 
    | UIUserNotificationType.Sound, 
    new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);

The user is presented with a permissions dialog. Once they have made their choices, the system calls UIAppDelegate.DidRegisterUserNotificationSettings.

The current permissions can be read with UIApplication.CurrentUserNotificationSettings.

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIUserNotificationSettings are listed below.

See Also: NSObject

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
CategoriesNSSet. Registered groups of actions for the app. (read-only)
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
TypesUIUserNotificationType. Notification types that the app is permitted to use.

Public Methods

Copy(NSZone) : NSObject
Performs a copy of the underlying Objective-C object.
static
GetSettingsForTypes(UIUserNotificationType, NSSet) : UIUserNotificationSettings
Gets settings that can be used to register the requested notification and action types.