TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

MAUI DotNet 7 simple sample please #204

Closed ClausElmann closed 11 months ago

ClausElmann commented 11 months ago

Could you please add a simple push notification sample app, It seem almost imposible for everybody to make i work, thanks in advance

andyzukunft commented 11 months ago

Hey Claus,

the Playground contains a Push example or am I mistaken?

Could you elaborate on what you require?

ClausElmann commented 11 months ago

Hey Claus,

the Playground contains a Push example or am I mistaken?

Could you elaborate on what you require?

Hey Andy

The Playground sample is .net 6 not 7 - and even if i try that on android emulator, i get this error Java.Lang.IllegalStateException: 'Default FirebaseApp is not initialized in this process com.tobishiba.playground. Make sure to call FirebaseApp.initializeApp(Context) first.'

andyzukunft commented 11 months ago

Hmm. I guess something broke when the package was redesigned. My application works just fine using .NET 7 and .NET 8 (basic tests, not used on iOS so far).

I will have a look - possibly create a dedicated demo application to simplify the implementation.

ClausElmann commented 11 months ago

Hmm. I guess something broke when the package was redesigned. My application works just fine using .NET 7 and .NET 8 (basic tests, not used on iOS so far).

I will have a look - possibly create a dedicated demo application to simplify the implementation.

Thanks, that would be awesome, can't wait to try it out 👍

andyzukunft commented 11 months ago

I created a demo app using .NET 7. I specifically specify the latest (.NET 7 supported) Android and iOS version and limit on how old Android and iOS version are allowed to be. I just prefer to control the versions more closely.

Please test if this works for you. If it does I will talk to Tobias if he wants a dedicated MAUI project just for Cloud Messaging.

Pull Request: https://github.com/TobiasBuchholz/Plugin.Firebase/pull/212 You can get the code directly from here: https://github.com/andyzukunft/Plugin.Firebase/tree/fcm-demo

Note: I also received the error Default FirebaseApp is not initialized in this process. This is because the google-service.json / Firebase Cloud Messaging is not properly configured. Please ensure you create you own Firebase project and use the correct google-service.json. I added the file to the gitignore so it won't get added by accident. Also: App only tested with Android as iOS adds additional complexity for interfacing Google and Apple.

ClausElmann commented 11 months ago

Great, thanks a lot. I will give it a spin tomorrow. I did download my own JSON file, but can't be sure if there is some issue with it. What was wrong with yours?

søn. 15. okt. 2023 22.56 skrev Andy Zukunft @.***>:

I created a demo app using .NET 7. I specifically specify the latest (.NET 7 supported) Android and iOS version and limit on how old Android and iOS version are allowed to be. I just prefer to control the versions more closely.

Please test if this works for you. If it does I will talk to Tobias if he wants a dedicated MAUI project just for Cloud Messaging.

Pull Request: #212 https://github.com/TobiasBuchholz/Plugin.Firebase/pull/212 You can get the code directly from here: https://github.com/andyzukunft/Plugin.Firebase

Note: I also received the error Default FirebaseApp is not initialized in this process. This is because the google-service.json / Firebase Cloud Messaging is not properly configured. Please ensure you create you own Firebase project and use the correct google-service.json. I added the file to the gitignore so it won't get added by accident. Also: App only tested with Android as iOS adds additional complexity for interfacing Google and Apple.

— Reply to this email directly, view it on GitHub https://github.com/TobiasBuchholz/Plugin.Firebase/issues/204#issuecomment-1763501986, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADGYH6TGQ2QRYJPKJHJENMDX7REZNAVCNFSM6AAAAAA5XWSWICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRTGUYDCOJYGY . You are receiving this because you authored the thread.Message ID: @.***>

andyzukunft commented 11 months ago

The project name in Firebase has to match the ApplicationId in the .csproj. I commented the relevant parts (I think).

You can attach the debugger in AppShell.xaml.cs after you have checked and provided all the necessary elements.

ClausElmann commented 11 months ago

Hi @andyzukunft

Great, it works now, I get the FCM Token.

I had to delete my Firebase project, and recreate it, so something must have been wrong there.

andyzukunft commented 11 months ago

Sounds great. Happy to help!