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 AppDelegate - Overrides for handling remote notifications not available #23451

Closed
mikeparker104 opened this issue Jul 5, 2024 · 4 comments · Fixed by #23452
Closed

iOS AppDelegate - Overrides for handling remote notifications not available #23451

mikeparker104 opened this issue Jul 5, 2024 · 4 comments · Fixed by #23452
Assignees
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events partner Issue or Request from a partner team platform/iOS 🍎 proposal/open t/bug Something isn't working t/enhancement ☀️ New feature or request
Milestone

Comments

@mikeparker104
Copy link
Contributor

Description

In Xamarin.Forms, the following UIApplicationDelegate methods could be overridden on FormsApplicationDelegate.

public virtual void RegisteredForRemoteNotifications (UIKit.UIApplication application, Foundation.NSData deviceToken);
public virtual void ReceivedRemoteNotification (UIKit.UIApplication application, Foundation.NSDictionary userInfo);

These methods aren't exposed in MauiUIApplicationDelegate alongside with other UIApplicationDelegate methods like FinishedLaunching, OpenUrl, and PerformFetch. The methods must be directly exported instead.

As was the case with the more recently added PerformFetch method (#7957 - iOS AppDelegate - Override for PerformFetch is not available), this may also be a candidate for inclusion as part of ConfigureLifecycleEvents.

events.AddiOS(ios => ios.RegisteredForRemoteNotifications(HandleRegisteredForRemoteNotifications));
events.AddiOS(ios => ios.ReceivedRemoteNotification(HandleReceivedRemoteNotification));

Steps to Reproduce

  1. Try to override the RegisteredForRemoteNotifications and ReceivedRemoteNotification methods on iOS (AppDelegate)

Link to public reproduction project repository

No response

Version with bug

8.0.61 SR6.1

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

Directly export the requisite methods in the AppDelegate class.

[Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
public void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)  { ... }

[Export("application:didReceiveRemoteNotification:")]
public void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) { ... }

Relevant log output

No response

@mikeparker104 mikeparker104 added t/bug Something isn't working t/enhancement ☀️ New feature or request proposal/open area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events platform/iOS 🍎 labels Jul 5, 2024
@dotnet-policy-service dotnet-policy-service bot added the partner Issue or Request from a partner team label Jul 5, 2024
Copy link
Contributor

github-actions bot commented Jul 5, 2024

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!

Open similar issues:

Closed similar issues:

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

@mikeparker104
Copy link
Contributor Author

@jfversluis @mattleibow See draft PR (#23452) for proposed updates.

mikeparker104 added a commit that referenced this issue Jul 8, 2024
### Description of Change

Add ```RegisteredForRemoteNotifications``` and
```ReceivedRemoteNotification``` to ```MauiUIApplicationDelegate``` as
virtual methods to allow override. Add corresponding lifecycle events.

### Issues Fixed

Fixes [#23451](#23451)
@mattleibow
Copy link
Member

This is now fixed in .NET 9: #23452

The next preview will have this included.

@mattleibow mattleibow added this to the .NET 9 Planning milestone Jul 8, 2024
@PureWeen PureWeen modified the milestones: .NET 9 Planning, 9.0-preview7 Jul 8, 2024
@SergTomcat
Copy link

Correct me if I'm wrong, it won't be in 8? 9 is not even released...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-core-lifecycle XPlat and Native UIApplicationDelegate/Activity/Window lifecycle events partner Issue or Request from a partner team platform/iOS 🍎 proposal/open t/bug Something isn't working t/enhancement ☀️ New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants