firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
367 stars 131 forks source link

FirebaseMessagingClient does not set Initializer.ApplicationName, causing a warning from BaseClientService #259

Closed KalleOlaviNiemitalo closed 3 years ago

KalleOlaviNiemitalo commented 3 years ago

My application uses Firebase Cloud Messaging. When it is started, it logs this warning to a Google.Apis.Logging.ILogger that it registers with Google.ApplicationContext.RegisterLogger:

Google.Apis.Services.BaseClientService Warning: 0 : Application name is not set. Please set Initializer.ApplicationName property

It seems that the FirebaseMessagingClient constructor calls the FCMClientService constructor with a BaseClientService.Initializer instance whose ApplicationName property is not set: https://github.com/firebase/firebase-admin-dotnet/blob/e0473fae182d2fbe851839684379298a56f95445/FirebaseAdmin/FirebaseAdmin/Messaging/FirebaseMessagingClient.cs#L67-L71

That then causes the warning from the BaseClientService constructor: https://github.com/googleapis/google-api-dotnet-client/blob/703f7d6a34dcbf06e09ff7e36e59d747940f0c84/Src/Support/Google.Apis/Services/BaseClientService.cs#L164-L169

I don't see any way for my application to set Initializer.ApplicationName and thus avoid the issue that causes the warning. I suppose I could change the Google.Apis.Logging.ILogger implementation in my application to recognize and suppress this specific warning.

My application hit this issue with the following set of NuGet packages. These versions are a bit out of date but the relevant parts of the source code don't seem to have been changed since then.

hiranya911 commented 3 years ago

Thanks for reporting this. I can try to get this fixed in an upcoming release. Feel free to send a PR too.