Plugin.LocalNotification icon indicating copy to clipboard operation
Plugin.LocalNotification copied to clipboard

Notification Tapped not working on iOS / Xamarin.Forms

Open j-bbr opened this issue 2 years ago • 9 comments

Describe the bug No NotificationActionTapped or NotificationReceived events on Xamarin.Forms.

To Reproduce Steps to reproduce the behavior:

  1. Install Plugin
  2. subscribe to events
  3. Tap on Notification / Actions
  4. 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 avatar Jun 08 '23 07:06 j-bbr

@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);
        }
}

thudugala avatar Jun 17 '23 00:06 thudugala

I've tried it and unfortunately the other changes to UserNotificationCenterDelegate broke iOS Foreground Notifications

j-bbr avatar Jun 19 '23 15:06 j-bbr

@j-bbr can you please attach a sample project?

thudugala avatar Jun 20 '23 00:06 thudugala

@j-bbr Try version 10.1.7

thudugala avatar Jun 27 '23 12:06 thudugala

@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 avatar Jul 07 '23 01:07 Cinmay2014

@Cinmay2014 Yes please attach a sample project

thudugala avatar Jul 07 '23 05:07 thudugala

@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 avatar Jul 14 '23 14:07 Cinmay2014

@Cinmay2014 it works for me

image

thudugala avatar Jul 22 '23 01:07 thudugala

@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.

Cinmay2014 avatar Jul 24 '23 15:07 Cinmay2014