diff --git a/docs/platform-integration/appmodel/permissions.md b/docs/platform-integration/appmodel/permissions.md index e45c1a7496..01bc838f40 100644 --- a/docs/platform-integration/appmodel/permissions.md +++ b/docs/platform-integration/appmodel/permissions.md @@ -1,7 +1,7 @@ --- title: "Permissions" description: "Learn how to use the .NET MAUI Permissions class, to check and request permissions. This class is in the Microsoft.Maui.ApplicationModel namespace." -ms.date: 10/28/2024 +ms.date: 07/11/2025 no-loc: ["Microsoft.Maui", "Microsoft.Maui.ApplicationModel"] --- @@ -36,7 +36,7 @@ The following table uses ✔️ to indicate that the permission is supported and | [Phone](xref:Microsoft.Maui.ApplicationModel.Permissions.Phone) | ✔️ | ✔️ | ❌ | ❌ | | [Photos](xref:Microsoft.Maui.ApplicationModel.Permissions.Photos) | ❌ | ✔️ | ❌ | ✔️ | | [PhotosAddOnly](xref:Microsoft.Maui.ApplicationModel.Permissions.PhotosAddOnly) | ❌ | ✔️ | ❌ | ✔️ | -| [PostNotifications](xref:Microsoft.Maui.ApplicationModel.Permissions.PostNotifications) | ✔️ | ❌ | ❌ | ❌ | +| [PostNotifications](xref:Microsoft.Maui.ApplicationModel.Permissions.PostNotifications) | ✔️ | ✔️ | ❌ | ❌ | | [Reminders](xref:Microsoft.Maui.ApplicationModel.Permissions.Reminders) | ❌ | ✔️ | ❌ | ❌ | | [Sensors](xref:Microsoft.Maui.ApplicationModel.Permissions.Sensors) | ✔️ | ✔️ | ❌ | ❌ | | [Sms](xref:Microsoft.Maui.ApplicationModel.Permissions.Sms) | ✔️ | ✔️ | ❌ | ❌ | @@ -50,6 +50,13 @@ The following table uses ✔️ to indicate that the permission is supported and If a permission is marked as ❌, it will always return when checked or requested. +:::moniker range=">=net-maui-11.0" + +> [!NOTE] +> Starting with .NET MAUI in .NET 11, `PostNotifications` is also supported on iOS and Mac Catalyst. On Apple platforms, this permission uses `UNUserNotificationCenter.RequestAuthorization` to request notification authorization from the user. Unlike most iOS permissions, `PostNotifications` does not require an `Info.plist` usage description string. + +:::moniker-end + ## Checking permissions To check the current status of a permission, use the method along with the specific permission to get the status for. The following example checks the status of the [`LocationWhenInUse`](xref:Microsoft.Maui.ApplicationModel.Permissions.LocationWhenInUse) permission: @@ -95,6 +102,20 @@ A is thrown if the re > [!IMPORTANT] > On some platforms, a permission request can only be activated a single time. Further prompts must be handled by the developer to check if a permission is in the state, and then ask the user to manually turn it on. +:::moniker range=">=net-maui-11.0" + +### Requesting notification permissions + +To request notification posting permissions on Android, iOS, and Mac Catalyst, use the [`PostNotifications`](xref:Microsoft.Maui.ApplicationModel.Permissions.PostNotifications) permission: + +```csharp +var status = await Permissions.RequestAsync(); +``` + +On Android, this maps to the `POST_NOTIFICATIONS` manifest permission. On iOS and Mac Catalyst, this uses `UNUserNotificationCenter.RequestAuthorization` to request notification authorization from the user. If the user has previously denied the notification permission on iOS, the method returns and the user must enable notifications manually through the Settings app. + +:::moniker-end + ## Explain why permission is needed It's best practice to explain to your user why your application needs a specific permission. On iOS, you must specify a string that is displayed to the user. Android doesn't have this ability, and also defaults permission status to . This limits the ability to know if the user denied the permission or if it's the first time the permission is being requested. The method can be used to determine if an informative UI should be displayed. If the method returns `true`, this is because the user has denied or disabled the permission in the past. Other platforms always return `false` when calling this method.