Closed elprofesor0710 closed 1 year ago
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); } `
what if you test Shell.Current.GoToAsync
inside MainThread
?
I doesn't work either, even if you just put Console.WriteLine to get e.Notification.Data it doesn't trigger.
Try to call CrossFirebaseCloudMessaging.Current.NotificationTapped += NotificationTapped
in your MainPage
's ViewModel instead of the App
constructor.
@TobiasBuchholz thanks for your respose,CrossFirebaseCloudMessaging.Current.NotificationTapped += NotificationTapped works on android under App.cs but not on iOS, also when I tapped the push notification (iOS) the app crashes.
@TobiasBuchholz I also think that it should be included on the documentation, some developers will need the NotificationTapped event.
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.
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); } `