thomasgalliker / Plugin.FirebasePushNotifications

Receive and handle firebase push notifications in .NET MAUI apps
31 stars 3 forks source link

[Bug] do you have this working? #3

Closed developer9969 closed 1 month ago

developer9969 commented 9 months ago

Hi I am looking for a plugin that I can hook Push notification in maui .net 7 and 8 and came across this. Did you actually manage to get it working?

Really interested to know.. I get all sorts of issue with path length on win11 even though I have shortened my nuget path to just C:/nuget

Can you receive notification for both iOS and android?

thanks

thomasgalliker commented 9 months ago

Yeah, I know what you mean. There are some plugins but most of them are outdated or not working at all. I’m migrating an app from XF to MAUI .NET 7, but just for Android and iOS. My goal was to have something similar to the exising plugin (Plugin.FirebasePushNotification). It looks like this plugin is not maintained anymore and since we have a tight migration schedule, I had to act quickly.

The code in this library works for our cases. There is yet alot of cleanup work to be done. The original code is full of static state and has some major quality issues. I gonna tackle them as soon as I have some time. I keep you updated.

developer9969 commented 9 months ago

@thomasgalliker I am absolutely in the same position... None works and outdated and its such a critical mobile functionality. I am thinking of re-inventing the wheel myself but there is a lot to grasp specially on android... Please keep me uptodate.

thomasgalliker commented 9 months ago

The plan is to leave the current code base as it is and publish it as version 1.x in nuget.org. Can you check if the latest version of the nuget package works for you? https://www.nuget.org/packages/Plugin.FirebasePushNotifications

Later, I want to rework the code base, add some queuing to the push notification events, and more stuff. These changes are planned for a version 2.x and will introduce breaking API changes.

developer9969 commented 9 months ago

hi the problem I have and I believe its a xamarin.iOS issue is that the path is too long - I have win11 and I have already enabled long path but I get image

thomasgalliker commented 9 months ago

Just to be clear: This project here will not work with Xamarin, it targets .NET MAUI for Android and iOS.

developer9969 commented 9 months ago

that was not xamarin that was a brand new maui app net 7 or 8!! the packages used are not added by me but from your plugin..

  1. Create a maui app .net 7 or 8
  2. Add your plugin
  3. get that error on windows 11

also note that Microsoft did not rename any of their projects in either ios or android they still left the "xamarin namespace"

thomasgalliker commented 9 months ago

Obviously they left some nuget names. I have not a clue whats wrong there. I develop my app on MacOS with Rider IDE. But it slso works on Windows 10 with VS 2022. I would recommend to checkout code with short paths. Other than that, I‘m not a big help.

developer9969 commented 9 months ago

Hi I am not expecting anything , and thanks for sharing this.. but anyone with a windows 11 and using windows as the main developer machine will not be able to install it

https://developercommunity.visualstudio.com/t/An-error-occurred-on-client-Build1647054/10370055#T-ND10375724

and there are many issues around long path with workaround etc.. because of this my nugets are now on c:/nugets

thanks

thomasgalliker commented 9 months ago

Crazy, absolutely crazy. I was waiting with Windows 11.... just as I was waiting with Xamarin Forms >> MAUI migration. But after some time at the market we could expect things to be more mature and stable... Obviously not. I'm sorry to hear this.

Jawah537 commented 7 months ago

use plugin.firebase.cloudmessaging instead of plugin.firebase. I finally got it working yesterday for maui7, atleast until this package of Thomas is working on all devices :) Really excited for your finished package Thomas!

Jawah537 commented 7 months ago

You need a combo of plugin.firebase.cloudmessaging, plugin.firebase.auth and plugin.firebase.dynamiclinks. Use the Nuget package manager console NOT the nuget project editor, it wont work. I recommend always using the package manager console for all nuget packages to bypass the long path issue

developer9969 commented 7 months ago

@Jawah537 really interested in what you have it working . Do you have it working in both iOS and android? Do you use a PC or Mac. do you have a solution we can look at? many thanks

thomasgalliker commented 7 months ago

I‘m on it. Its a lot of legacy code to be cleaned up. There will also be a sample app which demonstrates all the features of the library. I‘m currently testing all the different notification types, if they‘re handled properly.

bondo11 commented 7 months ago

Can i check out your "Refactoring-cleanup" to see if this will solve our issues using notifications in MAUI .net 7 + .net 8

thomasgalliker commented 7 months ago

The current develop branch is published on nuget.org. The refactoring-cleanup branch is work-in-progress. Im still on it. I have some changes uncommited; so no guarantees that it works. 😏 Sorry for the delay. Its a lot going on right now.

thomasgalliker commented 5 months ago

Is anyone still interessted in this plugin? I just published a new pre-release of version 2.x on nuget.org: https://www.nuget.org/packages/Plugin.FirebasePushNotifications

If someone offers to integrate this nuget in their solution, I can assist with help. Most of the API calls should be self-explanatory or similar to the predecessor plugin.

There is also a pretty good sample app available under Samples/MauiSampleApp. Check it out. It demonstrates almost all features provided by the library.

dylix commented 5 months ago

I am using it, but am having issues getting it to work on IOS. It's probably unrelated though to your project :P i get a token, so that part works, but nothing else comes through. same pkg name as xamarin ver, same googleservice-info.plist.. so who knows

jkommeren commented 4 months ago

Is anyone still interessted in this plugin? I just published a new pre-release of version 2.x on nuget.org: https://www.nuget.org/packages/Plugin.FirebasePushNotifications

If someone offers to integrate this nuget in their solution, I can assist with help. Most of the API calls should be self-explanatory or similar to the predecessor plugin.

There is also a pretty good sample app available under Samples/MauiSampleApp. Check it out. It demonstrates almost all features provided by the library.

I'll give it a go! The issue I'm having right now with my current implementation is that notifications do not arrive on Android in release mode. Probably caused by AOT / trimming. Are you having similar issues?

dylix commented 4 months ago

I’ve been messing with the refactor branch and have got all the things working finally 😎

jkommeren commented 4 months ago

I’ve been messing with the refactor branch and have got all the things working finally 😎

Including android notifications in release mode? ❤️

Repro: deploy on Android in release mode. Close application. Send notification. Nothing happens?

dylix commented 4 months ago

I’ve been messing with the refactor branch and have got all the things working finally 😎

Including android notifications in release mode? ❤️

Repro: deploy on Android in release mode. Close application. Send notification. Nothing happens?

Yeppers, though I never had an issue with android in any of the branches, only ios was troublesome for me

thomasgalliker commented 4 months ago

I will try to reproduce your issues. Maybe its advisable if we deal with all these issues in separate threads (open new issue).

Please forgive my response times. I‘m very busy at the moment 🙃 (just as everyone of us, I guess).

jkommeren commented 4 months ago

I’ve been messing with the refactor branch and have got all the things working finally 😎

Including android notifications in release mode? ❤️ Repro: deploy on Android in release mode. Close application. Send notification. Nothing happens?

Yeppers, though I never had an issue with android in any of the branches, only ios was troublesome for me Thanks for that! That gave me the incentive to finally give it a go again! I also have the refactor branch op and running, thanks thomas for your work.

I think I've zeroed in on the issue, which is I think because I'm overriding FirebaseMessagingService in my own (Android) app to receive a data-only message and show it as a notication, thomas has created one too called PNFirebaseMessagingService but if I'm correct this code is not used in the sample. I suspect this will have the same issue.

Update: Confirmed, I now receive notifications with AOT and the high priority thing is working too if I just use the non-FirebaseMessagingService-override method, which is a lot farther I've ever made it.

Sorry for spamming the topic. As soon as I have time I'll verify using the PNFirebaseMessagingService and whether it too has the AOT bug.

chema-code commented 3 months ago

First of all, thank you very much for your work. Since other plugins cannot be compiled in visual studio (the path size problem).

I have tested version 2.2.2 with .net 8 to see if I can use it in my applications and it has worked very well, for now I have only had one problem on iOS and that is that with the app stopped it does not show me the push, but for now I have only tested that it works in general for Android and iOS.

Soon I will start including it in one of the apps.

Thank you very much again!!

KaraVehizen commented 3 months ago

Thanks for your work, we do have an android application working through MAUI that we want to deploy on IOS. I've hit the "path size problem" wall and ended up here trying to implement this plugin. I had no issue so far with android, but when trying to run the IOS application on debug mode the application crash during start-up :

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManager.ConfigurePlatform(FirebasePushNotificationOptions options) at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.Configure(FirebasePushNotificationOptions options) at Plugin.FirebasePushNotifications.MauiAppBuilderExtensions.<>cDisplayClass0_0.b3(UIApplication application, NSDictionary launchOptions) at Microsoft.Maui.MauiUIApplicationDelegate.<>cDisplayClass6_0.b1(FinishedLaunching del) at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[FinishedLaunching](IServiceProvider services, Action`1 action) at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions) ...

If you have any idea where this could come from i could definitly use some help. I'll keep on trying to resolve it anyway.

thomasgalliker commented 3 months ago

Thanks for your work, we do have an android application working through MAUI that we want to deploy on IOS. I've hit the "path size problem" wall and ended up here trying to implement this plugin. I had no issue so far with android, but when trying to run the IOS application on debug mode the application crash during start-up :

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManager.ConfigurePlatform(FirebasePushNotificationOptions options) at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.Configure(FirebasePushNotificationOptions options) at Plugin.FirebasePushNotifications.MauiAppBuilderExtensions.<>cDisplayClass0_0.b3(UIApplication application, NSDictionary launchOptions) at Microsoft.Maui.MauiUIApplicationDelegate.<>cDisplayClass6_0.b1(FinishedLaunching del) at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[FinishedLaunching](IServiceProvider services, Action`1 action) at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions) ...

If you have any idea where this could come from i could definitly use some help. I'll keep on trying to resolve it anyway.

I will start with another MAUI migration in 1-2 weeks from now. I will for sure look into this issue by then. Maybe earlier. Can you open a new issue, so we can keep track of this!

KaraVehizen commented 3 months ago

I'm still working on it. It seems the issue is related to this https://github.com/xamarin/GoogleApisForiOSComponents/issues/486 I am indeed testing it on a local iphone and deploying it from visual studio on windows, paired to a mac.

Right now i'm updating to net8.0 and i'll go back to it later, i'll open an issue if needed then.

nsmith1024 commented 2 months ago

Has anybody got this or anything else to do cross platform push on MAUI working. Every time i try to import anything y whole project gets trashed and i have to stat over with a new project. Using Visual Studio 2022 .NET MAUI

donmesserli commented 2 months ago

I would also like to know if anyone has successfully gotten this to work on both iOS and Android under .Net 8? I have an app that is running up against a deadline and I'm wondering it I have to change to something else.

developer9969 commented 2 months ago

Please note that MS has deprecated the iOS side of it so either you create your own bindings or kind of stuffed.

thomasgalliker commented 2 months ago

Im currently migrating a huge Xamarin app to .NET MAU (net8.0-android and -ios) @donmesserli This week I will care about firebase push notifications. So, if there is anything weing in this library, it will be fixed. We are building our app on top of this, no matter what.

@developer9969 what exactly is deprecated? A nuget package we depend on here?

Diaver commented 2 months ago

@thomasgalliker Hey! Can you please share if you don't mind, how to update the Notification Icon and how to handle Tap on Notification? because right now nothing really happens :(

Thank you a lot!

gabsamples6 commented 1 month ago

@thomasgalliker Xamarin.Firebase.iOS.CloudMessaging will not longer be maintained and progressed by Microsoft so very soon your plugin will not longer work for iOS,

see these thread https://github.com/dotnet/maui/discussions/20359

thomasgalliker commented 1 month ago

Is there any replacement?

gabsamples6 commented 1 month ago

Officially no. They said we will provide u with some slim binding but no nugets

There is a guy in that thread that has moved them forward but now you are dependent on an individual. I am trying to make it work with azure hub as seems supported and they support fcmv1

but having some problems when app state is killed.

However MS support is absolutely rubbish

does your library work in all appstates in android? Foreground background and killed? Using androind 14?

thomasgalliker commented 1 month ago

Ok. Thanks for your response. I‘ll try to follow-up on this thread.

Regarding app states on Android: Yes, of course, I try to support all app states in this plugin. We need to have this in all our apps. If you have troubles using this plugin, consider opening a new issue and we can troubleshoot the problem.

If .NET MAUI does no longer provide support for Firebase on iOS, we will move to native push notifications:

We tried to avoid this „dual“ way because it makes things more complicated in the app and in the backend. If we are forced to go down this road, I‘ll rewrite this plugin.

MPoels commented 1 month ago

Hi Thomas,

Great work sofar! I have an app that will be released for Android and Ios later on .net 8.0, it is a ported xamarin.forms project. I was very happy with your project as I only had to change very little.

I managed to install the production version 1.0.26. with the usual path issues. C:\Nuget resolved and the registry patch resolved that.

On Android it all works.

I now suffer from 1 already reported issue: The iOS version (debug - native device) does not start and gives a "null reference exception" on start, it only reports that it is in Plugin.FirebasePushNotifications.

I will try the pre-release 2.0.16 and see how that's behaving...

donmesserli commented 1 month ago

How does the discontinuation of FCM affect the plugin. From what I understand, their classic APIs won't work anymore, but the v1 APIs will. Also, they no longer provide a backend and you have to roll your own and keep track of tokens, etc. Am I incorrect? I received a long explanation from OneSignal about it.

thomasgalliker commented 1 month ago

@donmesserli I think you will just have to use Google‘s latest Firebase Admin SDK which uses the „new“ FCM V1 API and you‘ll be fine. If you send FCM messages using your own implementation, you‘ll have to use the V1 API URL POST https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send as described here.

As far as I know - please correct if I‘m wrong - the change from FCM legacy API to FCM V1 API has no effect on the client-side implementation (in the app). But again, confirm/correct me on this if you have other knowledge.

thomasgalliker commented 1 month ago

Dear all! Thanks for all the feedback in this topic! We can get this thing to work but it requires more effort. I‘m currently working long days and nights to get things sorted out. Version 1.x of this plugin was pretty ugly, with lots of static code, contradiction, duplication,… Version 2.x and later should be more modern, cleaned-up and easier to use. There will be breaking changes if you upgrade major versions. I hope you bear with me and don‘t give up! I‘ll be there to answer questions as good as I can and in the time I have left for open source projects.

To continue in a more structured way, I‘d like to close this issue. Please open a new issue if you experience a problem or create a new discussion if you want to share your ideas, code snippets, etc…