Notification Tapped not working on iOS / Xamarin.Forms
Describe the bug No NotificationActionTapped or NotificationReceived events on Xamarin.Forms.
To Reproduce Steps to reproduce the behavior:
- Install Plugin
- subscribe to events
- Tap on Notification / Actions
- Nothing happens
Expected behavior A clear and concise description of what you expected to happen. Notification Events firing
Screenshots If applicable, add screenshots to help explain your problem.
Platform (please complete the following information):
- OS: [e.g. iOS] iOS 16
- Version [e.g. 22]: 10.1.5
Smartphone (please complete the following information):
- Device: [e.g. iPhone6] IPhone Simulator / Physical Device
- OS: [e.g. iOS8.1] 16
- Version [e.g. 22] 10.1.5
Additional context
Add any other context about the problem here.
I noticed that the Plugin comes with it's own Notification Delegate for iOS as described here. But I haven't seen where it's actually initialized in the documentation or the sample. So setting it in AppDelegate.FinishedLaunching like this:
UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
gave me the expected behaviour. Happy to add that to the documentation if desired.
@j-bbr please try version 10.1.6, make sure to call LocalNotificationCenter.SetUserNotificationCenterDelegate();
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LocalNotificationCenter.SetUserNotificationCenterDelegate();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
public override void WillEnterForeground(UIApplication uiApplication)
{
LocalNotificationCenter.ResetApplicationIconBadgeNumber(uiApplication);
base.WillEnterForeground(uiApplication);
}
}
I've tried it and unfortunately the other changes to UserNotificationCenterDelegate broke iOS Foreground Notifications
@j-bbr can you please attach a sample project?
@j-bbr Try version 10.1.7
@j-bbr please try version 10.1.6, make sure to call LocalNotificationCenter.SetUserNotificationCenterDelegate();
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate { public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); LocalNotificationCenter.SetUserNotificationCenterDelegate(); LoadApplication(new App()); return base.FinishedLaunching(app, options); } public override void WillEnterForeground(UIApplication uiApplication) { LocalNotificationCenter.ResetApplicationIconBadgeNumber(uiApplication); base.WillEnterForeground(uiApplication); } }
I have the same issue. I tried this method, but still not working. Notification pops up, but the tapped action doesn't work. if needed, I will attach a sample project. Already in the newest version. @thudugala
@j-bbr Did you solve your problem?
@Cinmay2014 Yes please attach a sample project
@thudugala Hi Elvin, attached is the sample project. It works fine for Android but failed for iOS. If you have time, please check it. Really appreciate it. https://github.com/Cinmay2014/sample01
@Cinmay2014 it works for me
@thudugala Can you test the weekly notification? when the weekly notification pops up and it is clicked, nothing happened. It should navigate to the weeklytips page.