Skip to content

Add PostNotifications implementation for iOS#30132

Merged
jfversluis merged 1 commit into
dotnet:net11.0from
IeuanWalker:main
Mar 16, 2026
Merged

Add PostNotifications implementation for iOS#30132
jfversluis merged 1 commit into
dotnet:net11.0from
IeuanWalker:main

Conversation

@IeuanWalker
Copy link
Copy Markdown

@IeuanWalker IeuanWalker commented Jun 23, 2025

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

Added PostNotifications implementation for iOS

Issues Fixed

Fixes #23962
Not sure why the issue was closed as Not planned

Copilot AI review requested due to automatic review settings June 23, 2025 12:28
@IeuanWalker IeuanWalker requested a review from a team as a code owner June 23, 2025 12:28
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Jun 23, 2025

This comment was marked as outdated.

@IeuanWalker
Copy link
Copy Markdown
Author

Hoping to test via the artifact, struggling to get the whole .sln to build locally

@IeuanWalker IeuanWalker requested a review from Copilot June 23, 2025 12:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for notification permissions on iOS and updates sample manifests to reflect the new permission.

  • Implements the PostNotifications permission check and request on iOS.
  • Updates the iOS sample Info.plist to include remote‐notification background mode.
  • Adds the Android POST_NOTIFICATIONS permission to the sample Android manifest.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Essentials/src/Permissions/Permissions.ios.cs Adds PostNotifications permission implementation.
src/Essentials/samples/Samples/Platforms/iOS/Info.plist Adds UIBackgroundModes key for remote notifications.
src/Essentials/samples/Samples/Platforms/Android/AndroidManifest.xml Adds <uses-permission> for POST_NOTIFICATIONS.
Comments suppressed due to low confidence (2)

src/Essentials/src/Permissions/Permissions.ios.cs:253

  • There are no automated tests covering the new PostNotifications permission. Please add unit tests in TestCases.Shared.Tests and UI tests in TestCases.HostApp to verify both CheckStatusAsync and RequestAsync behaviors.
		public partial class PostNotifications : BasePlatformPermission

src/Essentials/src/Permissions/Permissions.ios.cs:253

  • The new PostNotifications permission should be documented in the public XML docs under /docs/ to describe its behavior, required entitlements, and sample usage.
		public partial class PostNotifications : BasePlatformPermission

@PureWeen
Copy link
Copy Markdown
Member

/azp run MAUI-public

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@jsuarezruiz jsuarezruiz added platform/ios area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info labels Jun 24, 2025
public partial class PostNotifications : BasePlatformPermission
{
/// <inheritdoc/>
#pragma warning disable RS0016
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to remove this and add the right entries to the API txt files. That will also mean we want to target this for .NET 10 as it adds new APIs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfversluis sorry what does that mean, is there anything i need too do?

Copy link
Copy Markdown
Member

@jfversluis jfversluis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 15, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 30132

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 30132"

@kubaflo
Copy link
Copy Markdown
Contributor

kubaflo commented Mar 15, 2026

I've rebased and cleaned up this PR with the following changes:

Addressing review feedback from @jfversluis:

  • ✅ Removed #pragma warning disable RS0016 — added proper PublicAPI.Unshipped.txt entries for both net-ios and net-maccatalyst instead
  • ✅ Fixed indentation consistency in sample files (tabs to match existing style)

Implementation improvements:

  • Handle UNAuthorizationStatus.Provisional and UNAuthorizationStatus.Ephemeral as Granted (original only handled Authorized and Denied)
  • Use TrySetResult instead of SetResult in TaskCompletionSource callbacks (safer pattern, matches existing Media permission implementation)
  • RequestAsync now calls CheckStatusAsync first to avoid unnecessary permission prompts when already granted (matches the pattern used by Microphone, Speech, etc.)
  • Added device test for PostNotifications.CheckStatusAsync

Rebased cleanly onto current main — the messy merge history is now a single clean commit.

Note: Per @jfversluis's comment about targeting .NET 10 since this adds new APIs, this PR may need its base branch changed to net10.0.

@kubaflo
Copy link
Copy Markdown
Contributor

kubaflo commented Mar 15, 2026

Changed base to net11

@kubaflo kubaflo changed the base branch from main to net11.0 March 15, 2026 21:28
@jfversluis
Copy link
Copy Markdown
Member

/rebase

- Implement CheckStatusAsync using UNUserNotificationCenter.GetNotificationSettings
- Implement RequestAsync using UNUserNotificationCenter.RequestAuthorizationAsync
- Handle Provisional and Ephemeral authorization statuses as Granted
- Check status before requesting to avoid unnecessary prompts
- Add PublicAPI.Unshipped.txt entries for net-ios and net-maccatalyst
- Remove #pragma warning disable RS0016 per review feedback
- Add POST_NOTIFICATIONS permission to Android sample manifest
- Add UIBackgroundModes to iOS sample Info.plist
- Add device test for PostNotifications.CheckStatusAsync
- Fix indentation consistency in sample files

Fixes #23962

Co-authored-by: Ieuan Walker <ieuan.walker007@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jfversluis
Copy link
Copy Markdown
Member

/azp run maui-pr

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@jfversluis jfversluis added this to the .NET 11.0-preview3 milestone Mar 16, 2026
@jfversluis jfversluis merged commit 41a3918 into dotnet:net11.0 Mar 16, 2026
27 checks passed
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

🚨 API change(s) detected @davidortinau FYI

@dotnet dotnet deleted a comment from dotnet-policy-service Bot Mar 16, 2026
davidortinau added a commit to dotnet/docs-maui that referenced this pull request Apr 10, 2026
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>
jfversluis pushed a commit to dotnet/docs-maui that referenced this pull request Apr 14, 2026
…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>
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info community ✨ Community Contribution platform/ios t/breaking 💥

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS PostNotifications permission check is always granted

6 participants