question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NotificationTapped not working

See original GitHub issue

Hi,

Can you please give us an example of NotificationTapped/NotificationReceived, navigating to other page? I tried something like this but it doen’t work both android and iOS. Really appreciate any help thanks in advance.

`public App() { CrossFirebaseCloudMessaging.Current.NotificationReceived += NotificationReceived; CrossFirebaseCloudMessaging.Current.NotificationTapped += NotificationTapped; }

void NotificationReceived(object source, FCMNotificationReceivedEventArgs e) { //use e.Notification.Data await Shell.Current.GoToAsync($“//{nameof(Home)}”, true); }

void NotificationTapped(object source, FCMNotificationTappedEventArgs e) { //use e.Notification.Data await Shell.Current.GoToAsync($“//{nameof(Home)}”, true); } `

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
TobiasBuchholzcommented, Jan 14, 2023

Try to call CrossFirebaseCloudMessaging.Current.NotificationTapped += NotificationTapped in your MainPage’s ViewModel instead of the App constructor.

0reactions
elprofesor0710commented, Jan 19, 2023

I can now confirm that it works for both android and iOS, just make sure in iOS AppDelegate.cs that there are no other method or event. also make sure that you delete the obj and bin files when you need to build/release the app.

this will work:

public App()
{
CrossFirebaseCloudMessaging.Current.NotificationReceived += NotificationReceived;
CrossFirebaseCloudMessaging.Current.NotificationTapped += NotificationTapped;
}

void NotificationReceived(object source, FCMNotificationReceivedEventArgs e)
{
//use e.Notification.Data
await Shell.Current.GoToAsync($"//{nameof(Home)}", true);
}

void NotificationTapped(object source, FCMNotificationTappedEventArgs e)
{
//use e.Notification.Data
await Shell.Current.GoToAsync($"//{nameof(Home)}", true);
}

What I suggest is to add this on the documentation, other developers might need it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't get NotificationTapped Event working #32
Describe the bug. I have the NotificationCenter.Current.NotificationTapped += Current_NotificationTapped; in the App.xaml.cs file above the ...
Read more >
Xamarin.forms NotificationTapped event not fired when tap ...
1) NotificationTapped this event is not fired when you tap on notification? Some times break point will not hit.
Read more >
Push notifications in .NET MAUI with Firebase
This looks useful. The problem is that I do not get FCM Token I am trying to get it just when clicking a...
Read more >
Open app in specific view when push notification is tapped
The problem with this approach is that by replacing the root view controller with the new view controller, we have removed the whole...
Read more >
Native Mobile Spec | Segment Documentation
One of the core components of the Segment Spec is the track method. It records any arbitrary event that the user has triggered....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found