Skip to content

Error Getting FCM Token #1

@christopherhofmeister

Description

@christopherhofmeister

Hi Max,

First of all, thanks much for putting together this project and the video on YouTube.

I followed along with the steps in your video, but was unable to get a token from the GetTokenAsync() method. I am starting with Android implementation.

I cloned your GitHub project and made just a few changes, such as:
-changed app identifier to match the one in my google-services.json file.
-Added my google-services.json file to the project.

I am getting the same error in your project as I am in my project.
[DOTNET] Error: Default FirebaseApp is not initialized in this process com.xxx.yyyy. Make sure to call FirebaseApp.initializeApp(Context) first.

Perhaps I am doing something wrong, or there has been a change along the way? I am going to dig into the error, but also wondering if you have any ideas.

FYI I modified the code in the project to capture this exception:

private async void OnCounterClicked(object sender, EventArgs e)
{
    try
    {
        await CrossFirebaseCloudMessaging.Current.CheckIfValidAsync();
        var token = await CrossFirebaseCloudMessaging.Current.GetTokenAsync();
        Console.WriteLine($"FCM token: {token}");
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error: {ex.Message}");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions