Closed swagdkau closed 3 weeks ago
Should mention that we are running .NET 8.0 for both Android and iOS - all newest version and newest VS 2022 (as indicated in the original edit). I can supplement and say - that for iOS .NET 8.0 - the sample app works out of the box. Thus, the problem seems to be related to the file google-services,json - and in particular - that in .NET 8.0, we cannot add the build action GoogleServicesJson in Visual Studio 2022. This indicates to me that something is broken in the automated loading of the file. A new feature that would allow us to manually add the parameters would be a great example and allow us to test Firebase Push end-2-end.
Ok. Yes I've seen this in the past, that VS2022 doesn't give the build action GoogleServicesJson. You can copy the build statements from the sample app, I think VS should still be smart enough to treat those files as GoogleServicesJson after that:
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<GoogleServicesJson Include="Platforms\Android\Resources\google-services.json" Link="Platforms\Android\Resources\google-services.json" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
<BundleResource Include="Platforms\iOS\GoogleService-Info.plist" Link="GoogleService-Info.plist" />
</ItemGroup>
Regarding the Firebase options: Good idea. So you'd like to provide the Firebase options in code rather than providing a google-services.json file, right? I think there is an option in FirebaseApp.Initialize(...) method, but I'd have to research about it. Let's open a new issue where we describe the enhancement.
Do I understand you correctly, that this issue is actually solved?
Already tried all that.
Did not work.
Actually, the build actions are already in your Github project file.
I suspect there is some library that I am missing – and the lack of the build action is what is causing this.
I have the exact same problem (on Android) with .NET 8.0 on other frameworks. In .NET 8.0 – the file is simply never read. However, rolling back to .NET 6.0 – it works !!!
But, let us leave it be. I have it working on iOS .NET 8.0 – which is really want I wanted. The Android was just to get a reference for comparing how it works.
Thank you for your time.
PS Andrew Richie from Shiny says – that Firebase Push notifications are not working for them on Android – but Azure Push Notifications are … This indicates that Microsoft broke something. Would not be the first time 😉
Kind regards,
Stefan Wagner, PhD Associate Professor Biomedical Section Department of Electrical and Computer Engineering Aarhus University
Phone: +45 4189 3254 Email: @.***
Head of Biomedical & Pervasive Systemshttps://ece.au.dk/forskning/forsknings-og-udviklingsomraader/biomedical-engineering/research-groups/biomedical-pervasive-systems/ Research Group Head of Ambient Assisted Living Lab From: Thomas Galliker @.> Sent: Friday, October 18, 2024 11:28 AM To: thomasgalliker/Plugin.FirebasePushNotifications @.> Cc: Stefan Rahr Wagner @.>; Author @.> Subject: Re: [thomasgalliker/Plugin.FirebasePushNotifications] [Bug] Sample project fails to accept google-services.json file build property GoogleServicesJson (Issue #75)
Ok. Yes I've seen this in the past, that VS2022 doesn't give the build action GoogleServicesJson. You can copy the build statements from the sample app, I think VS should still be smart enough to treat those files as GoogleServicesJson after that:
Regarding the Firebase options: Good idea. So you'd like to provide the Firebase options in code rather than providing a google-services.json file, right? I think there is an option in FirebaseApp.Initialize(...) method, but I'd have to research about it. Let's open a new issue where we describe the enhancement.
Do I understand you correctly, that this issue is actually solved?
— Reply to this email directly, view it on GitHubhttps://github.com/thomasgalliker/Plugin.FirebasePushNotifications/issues/75#issuecomment-2421957997, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AY4UTA3ON7ILELWS4DZVTJ3Z4DIALAVCNFSM6AAAAABQBIDHLSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRRHE2TOOJZG4. You are receiving this because you authored the thread.Message ID: @.**@.>>
The latest 2.5.x stable version has an improved bootstrap procedure with more logging during startup. If you configure Microsoft.Extensions.Logging in your app, observe what log output you receive during the startup of your app.
If there are unsolvable troubles, please don't hesitate to ask again. Since I cannot reproduce this issue, I'm going to close it for now.
Thank you Thomas. "Do I understand you correctly, that this issue is actually solved?" The build action still does not work for me in the Android project, but your sample app works on iOS, which is where I really need it. I only started with Android to have an AB reference. I will leave the Android solution for the future.
"Regarding the Firebase options: Good idea. So you'd like to provide the Firebase options in code rather than providing a google-services.json file, right? I think there is an option in FirebaseApp.Initialize(...) method, but I'd have to research about it. Let's open a new issue where we describe the enhancement."
Exactly. I would actually rather want to feed this information from a server or a settings file, rather than from a firebase generated file. It is only a few fields that are actually relevant. I just found it strange that this is not an option.
Thank you for your time.
Great. Thank you.
Kind regards,
Stefan Wagner, PhD Associate Professor Biomedical Section Department of Electrical and Computer Engineering Aarhus University
Phone: +45 4189 3254 Email: @.***
Head of Biomedical & Pervasive Systemshttps://ece.au.dk/forskning/forsknings-og-udviklingsomraader/biomedical-engineering/research-groups/biomedical-pervasive-systems/ Research Group Head of Ambient Assisted Living Lab From: Thomas Galliker @.> Sent: Tuesday, October 29, 2024 11:17 AM To: thomasgalliker/Plugin.FirebasePushNotifications @.> Cc: Stefan Rahr Wagner @.>; Author @.> Subject: Re: [thomasgalliker/Plugin.FirebasePushNotifications] [Bug] Sample project fails to accept google-services.json file build property GoogleServicesJson (Issue #75)
The latest 2.5.x stable version has an improved bootstrap procedure with more logging during startup. If you configure Microsoft.Extensions.Logging in your app, observe what log output you receive during the startup of your app.
If there are unsolvable troubles, please don't hesitate to ask again. Since I cannot reproduce this issue, I'm going to close it for now.
- Reply to this email directly, view it on GitHubhttps://github.com/thomasgalliker/Plugin.FirebasePushNotifications/issues/75#issuecomment-2443804976, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AY4UTAZPOOTKDUODILWZOH3Z55ODDAVCNFSM6AAAAABQBIDHLSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBTHAYDIOJXGY. You are receiving this because you authored the thread.Message ID: @.**@.>>
Description
Trying to run the standard sample project from Plugin.FirebasePushNotifications. The files google-services,json is missing (in git ignore) - but I add the one that works for .NET 7.0. Code builds without problems Sample App Launches on Device target (Android 14, Samsung A52) Fails In the code FirebasePushNotificationManager.cs lines 48 "FirebaseMessaging.Instance.AutoInitEnabled = this.options.AutoInitEnabled;" it fails with the exception : "Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.companyname.firebasepushdemo. Make sure to call FirebaseApp.initializeApp(Context) first.'"
Output: Start debugging Android application ... Forwarding debugger port 8887 Detecting existing process
The thread 8 has exited with code 0 (0x0). Thread finished: #8 [TrafficStats] tagSocket(97) with statsTag=0xffffffff, statsUid=-1 [CompatibilityChangeReporter] Compat change id reported: 263076149; UID 10599; state: ENABLED [TrafficStats] tagSocket(97) with statsTag=0xffffffff, statsUid=-1
this.options.AutoInitEnabled = true;
if (this.options.AutoInitEnabled) { try { var context = Platform.CurrentActivity; Firebase.FirebaseApp.InitializeApp(context); } catch (Exception ex) { this.logger.LogError(ex, "FirebaseApp.InitializeApp failed with exception. " + "Make sure the google-services.json file is present and marked as GoogleServicesJson."); throw; } }
Steps to Reproduce
Using VS 2022 17.11.5 on Windows 11 Pro Xamarin 17.11..0.98 Xamarin.Android SDK
1) Cloning github repo Plugin.FirebasePushNotifications using git. 2) Starting in Visual Studio 2022 3) Adding own google-services.json file - which works with a different API in .NET 6.0 MAUI - tested using FCM API. I am adding it under Platforms/Android/Resources as instructed. 4) I am NOT allowed to apply the build action GoogleServicesJson in the property of the file. This could be indicative of the problem. Several suggestions can be Googled - none works. Guess some work around exists - since last code update was made 2 days ago. 5) Instead added manually 6) Code fails in FirebasePushNotificationManager.cs lines 48 "FirebaseMessaging.Instance.AutoInitEnabled = this.options.AutoInitEnabled;" it fails with the exception : "Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.companyname.firebasepushdemo. Make sure to call FirebaseApp.initializeApp(Context) first.'"
Expected Behavior
That the app would build and run. Maybe allow me to set build action on file google-services.json
Actual Behavior
Code fails in FirebasePushNotificationManager.cs lines 48 "FirebaseMessaging.Instance.AutoInitEnabled = this.options.AutoInitEnabled;" it fails with the exception : "Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.companyname.firebasepushdemo. Make sure to call FirebaseApp.initializeApp(Context) first.'"
Basic Information
Screenshots, Attachments, Links