How do I navigate to page using firebase tabbed event

97786402 20 Reputation points
2023-08-14T10:53:15.02+00:00
Hi,

could not navigate to specific page on firebase notification tabbed event with oncreate method

code is running ok. but tabbed event not triggering.

checked on both dotnet7 and dotnet6
checke with  and without foreground service

I read your comment in another post, in which you told to use 6.0.312 vut could not use the exact version, if this is the case then how can I integrate 6.0.312 in project.

Regards,
mauiprogram.cs

    private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder)
    {
        builder.ConfigureLifecycleEvents(events => {
#if IOS
            events.AddiOS(iOS => iOS.FinishedLaunching((app, launchOptions) => {
                CrossFirebase.Initialize(CreateCrossFirebaseSettings());
                CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true);
                return false;
            }));
#else
            events.AddAndroid(android => android.OnCreate((activity, _) =>
                CrossFirebase.Initialize(activity, CreateCrossFirebaseSettings())));
                CrossFirebaseCrashlytics.Current.SetCrashlyticsCollectionEnabled(true);
            CrossFirebaseCloudMessaging.Current.NotificationTapped += (sender, e) =>
            {
                System.Diagnostics.Debug.WriteLine("tabbed");
                Shell.Current.GoToAsync(nameof(Specspage));
            };
#endif
        });

        builder.Services.AddSingleton(_ => CrossFirebaseAuth.Current);
        return builder;
    }
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,075 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,417 questions
{count} votes

Accepted answer
  1. Leo Wagner de Souza 696 Reputation points
    2023-08-17T15:30:28.5566667+00:00

    Please note that you implemented the NotificationTapped only on Android, so it will not work on iOS.

    Also, this code is not enough to determine if you are initializing the Plugin.Firebase correctly.

    Here is a sample, with Plugin.Firebase + .NET7 + MAUI that works fine on iOS, please check the complete plugin initialization.

    https://github.com/leowagnersouza/fcmmaui

    Also, on the Tapped event, check if if you have a valid instance:

    if (CrossFirebaseCloudMessaging.Current != null)

    And if you have a valid notification:

    if (e != null && e.Notification != null && e.Notification.Data != null)

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.