Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Lifecycle for push notifications needs to be conditionally implemented #24237

Open
Redth opened this issue Aug 14, 2024 · 5 comments
Open
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst proposal/open s/triaged Issue has been reviewed

Comments

@Redth
Copy link
Member

Redth commented Aug 14, 2024

Description

For .NET 9 Preview 7, we added iOSLifecycle.OnReceivedRemoteNotifications and iOSLifecycle.OnRegisteredForRemoteNotifications lifecycle events in #23452 (Yay!)

But we forgot to ensure that for cases when an app does not want these implemented, it needs to appear to Apple that it is not using them, otherwise I believe apps will be flagged in submission for not including the appropriate entitlements (need to fact check this).

I believe we could do this by overriding RespondsToSelector on the delegate and checking for these selectors and returning false if we have determined the app isn't actually wiring up the registration (need to fact check this).

We need to decide how we want to determine that. Maybe we can look at the entitlements at runtime and see if aps entitlement is declared? or we can set a flag when registering for the lifecycle event, however this may conflict with cases where someone manually overrides these methods on their delegate. We could also have a property on the delegate to toggle this on and off.

Version with bug

9.0.0-preview.7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

9.0.0-preview.6

Affected platforms

iOS, macOS

Did you find any workaround?

For now, one could manually override RespondsToSelector and return false when these are queried if they do not want to appear to have them implemented.

Thanks @aritchie for noticing this change and helping flag the potential issues with it!

@Redth Redth added t/bug Something isn't working area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events p/0 Work that we can't release without i/regression This issue described a confirmed regression on a currently supported version labels Aug 14, 2024
@Redth Redth added this to the 9.0-rc1 milestone Aug 14, 2024
@dotnet-policy-service dotnet-policy-service bot added the s/triaged Issue has been reviewed label Aug 14, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@mattleibow
Copy link
Member

There is also another warning in the console if you run about some other override. I forget exactly, so when I get to my mac I can update this issue.

@aritchie
Copy link
Contributor

There is also another warning in the console if you run about some other override. I forget exactly, so when I get to my mac I can update this issue.

PerformFetch

For .NET 9 Preview 7, we added iOSLifecycle.OnReceivedRemoteNotifications and iOSLifecycle.OnRegisteredForRemoteNotifications lifecycle events in #23452 (Yay!)

You're missing:

  [Export("application:didFailToRegisterForRemoteNotificationsWithError:")]
  public void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)

@Redth
Copy link
Member Author

Redth commented Aug 14, 2024

Ok, sounds like responds to selector will not be enough, and that the static analysis apple does is going to flag the inclusion of it. We may need to revert these changes for now.

@aritchie
Copy link
Contributor

Apple doesn't care about the PerformFetch as much since it is deprecated, but they will not be happy with push hooks if they aren't actually being used. I've been trying to solve this one for a while, but just gave up and document the fact that you have to hook these methods manually

@PureWeen PureWeen modified the milestones: 9.0-rc1, 9.0-rc2 Aug 23, 2024
@PureWeen PureWeen moved this from Todo to In Progress in MAUI SDK Ongoing Aug 29, 2024
Redth added a commit that referenced this issue Sep 24, 2024


Unfortunately, when these lifecycle events were added, we didn't consider the implications of having the methods implemented on the appdelegate had with Apple app store submissions.  Basically if the app delegate implements these methods, Apple assumes in their static analysis of the submitted apps that you intend to use them, and will warn about requiring the appropriate entitlements to therefore be declared.

Given there's no obvious/easy way to conditionally export these selectors at this time, we are reverting the change to maintain the no warning/no error submission behaviour.

For more information and to track future potential implementations of these lifecycle events, follow: #24237
Redth added a commit that referenced this issue Sep 24, 2024


Unfortunately, when these lifecycle events were added, we didn't consider the implications of having the methods implemented on the appdelegate had with Apple app store submissions.  Basically if the app delegate implements these methods, Apple assumes in their static analysis of the submitted apps that you intend to use them, and will warn about requiring the appropriate entitlements to therefore be declared.

Given there's no obvious/easy way to conditionally export these selectors at this time, we are reverting the change to maintain the no warning/no error submission behaviour.

For more information and to track future potential implementations of these lifecycle events, follow: #24237
rmarinho pushed a commit that referenced this issue Sep 25, 2024
…thods (#24907)

* Revert:  Add MauiUIApplicationDelegate remote notification methods #23452

Unfortunately, when these lifecycle events were added, we didn't consider the implications of having the methods implemented on the appdelegate had with Apple app store submissions.  Basically if the app delegate implements these methods, Apple assumes in their static analysis of the submitted apps that you intend to use them, and will warn about requiring the appropriate entitlements to therefore be declared.

Given there's no obvious/easy way to conditionally export these selectors at this time, we are reverting the change to maintain the no warning/no error submission behaviour.

For more information and to track future potential implementations of these lifecycle events, follow: #24237

* Remove delegates
@PureWeen PureWeen modified the milestones: 9.0-rc2, .NET 10 Planning Sep 25, 2024
@PureWeen PureWeen added proposal/open and removed p/0 Work that we can't release without i/regression This issue described a confirmed regression on a currently supported version t/bug Something isn't working labels Sep 25, 2024
Redth added a commit to dotnet/docs-maui that referenced this issue Oct 8, 2024
In previews we had added new app lifecycle events for iOS push notifications, but have removed them from GA since there are potential issues with app store submissions the way they have been added.

This change reverts them: dotnet/maui#24907

This issue tracks adding them back in the future:
dotnet/maui#24237
davidbritch added a commit to dotnet/docs-maui that referenced this issue Oct 8, 2024
* Remove previously added iOS App Lifecycle events for push

In previews we had added new app lifecycle events for iOS push notifications, but have removed them from GA since there are potential issues with app store submissions the way they have been added.

This change reverts them: dotnet/maui#24907

This issue tracks adding them back in the future:
dotnet/maui#24237

* Remove extra blank line

* Also remove events from app lifecycle doc.

---------

Co-authored-by: David Britch <davidbritch@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events platform/iOS 🍎 platform/macOS 🍏 macOS / Mac Catalyst proposal/open s/triaged Issue has been reviewed
Projects
None yet
Development

No branches or pull requests

5 participants