You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document iOS/Mac Catalyst PostNotifications permission support (.NET 11) (#3280)
Update the permissions article to reflect that Permissions.PostNotifications
is now supported on iOS and Mac Catalyst, added in .NET 11 Preview 3
(dotnet/maui#30132). Changes include:
- Update platform support table: PostNotifications iOS column ❌ → ✔️
- Add moniker-gated note explaining the new Apple platform support
- Add code example for requesting notification permissions
- Note that iOS uses UNUserNotificationCenter.RequestAuthorization
and does not require an Info.plist usage description string
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/platform-integration/appmodel/permissions.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Permissions"
3
3
description: "Learn how to use the .NET MAUI Permissions class, to check and request permissions. This class is in the Microsoft.Maui.ApplicationModel namespace."
@@ -50,6 +50,13 @@ The following table uses ✔️ to indicate that the permission is supported and
50
50
51
51
If a permission is marked as ❌, it will always return <xref:Microsoft.Maui.ApplicationModel.PermissionStatus.Granted> when checked or requested.
52
52
53
+
:::moniker range=">=net-maui-11.0"
54
+
55
+
> [!NOTE]
56
+
> 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.
57
+
58
+
:::moniker-end
59
+
53
60
## Checking permissions
54
61
55
62
To check the current status of a permission, use the <xref:Microsoft.Maui.ApplicationModel.Permissions.CheckStatusAsync%2A?displayProperty=nameWithType> 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 <xref:Microsoft.Maui.ApplicationModel.PermissionException> is thrown if the re
95
102
> [!IMPORTANT]
96
103
> 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 <xref:Microsoft.Maui.ApplicationModel.PermissionStatus.Denied> state, and then ask the user to manually turn it on.
97
104
105
+
:::moniker range=">=net-maui-11.0"
106
+
107
+
### Requesting notification permissions
108
+
109
+
To request notification posting permissions on Android, iOS, and Mac Catalyst, use the [`PostNotifications`](xref:Microsoft.Maui.ApplicationModel.Permissions.PostNotifications) permission:
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 <xref:Microsoft.Maui.ApplicationModel.PermissionStatus.Denied> and the user must enable notifications manually through the Settings app.
116
+
117
+
:::moniker-end
118
+
98
119
## Explain why permission is needed
99
120
100
121
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 <xref:Microsoft.Maui.ApplicationModel.PermissionStatus.Disabled>. 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 <xref:Microsoft.Maui.ApplicationModel.Permissions.ShouldShowRationale%2A> 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.
0 commit comments