andrei-m-code / net-core-push-notifications

Lightweight .NET Core Push Notifications for Android, iOS and Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use?

amercobra opened this issue · comments

commented

Hi,

Great work. Though I have been trying for a couple of days using it with no luck. I made sure all is ok in my code including server id, token.. I tried my own simpler code and it worked.

Can you guide me please how to call "SendAsync" for example? I doubt that I'm not using the Payload/Notification correctly.

Appreciated.

Here is a sample of my code:

        String serverId = "xyz"; //from FCM console
        String senderId = "xyz"; //from FCM console
        String deviceToken = "xyz"; //from my device (which i receive notificaiton from above serverId)

        GoogleNotification notification1 = new GoogleNotification();
        notification1.Data = new GoogleNotification.DataPayload();
        notification1.Data.Message = "some message";
        notification1.Priority = "high";

        using (var fcm = new FcmSender(serverId, senderId))
        {
            await fcm.SendAsync(deviceToken, notification1); 
        }   

@amercobra if FCM serverId and senderId is configured correctly, I don't see any issues in your C# code. However of course there may be something on the receiver (Android?) side. I could take a look at your Android manifest and other code that receives notification.

Is there any future information about this issue?
seems like I have the same issue. I don't know whats wrong.

btw, is there any respond if that code above successfuly or fail? Since i didnt get any response even success or fail

@arhen @amercobra you can actually examine the response from fcm, e.g.:

var response = await fcm.SendAsync(...);

Check the response object and see if it can help you troubleshoot your issue. My first guess is: you guys didn't set it up right. Some keys are wrong or something else. Hard to guess, as there are many moving pieces.

@arhen @amercobra you can actually examine the response from fcm, e.g.:

var response = await fcm.SendAsync(...);

Check the response object and see if it can help you troubleshoot your issue. My first guess is: you guys didn't set it up right. Some keys are wrong or something else. Hard to guess, as there are many moving pieces.

yeah, I've figure out later after look deep onto the source code. I think it's docless so I can't understand the response template (for someone that less exp on FCM).

Sorry I didn't reply it ASAP on this issue

commented

@arhen @amercobra you can actually examine the response from fcm, e.g.:

var response = await fcm.SendAsync(...);

Check the response object and see if it can help you troubleshoot your issue. My first guess is: you guys didn't set it up right. Some keys are wrong or something else. Hard to guess, as there are many moving pieces.

yeah, I've figure out later after look deep onto the source code. I think it's docless so I can't understand the response template (for someone that less exp on FCM).

Sorry I didn't reply it ASAP on this issue

Hi @arhen ,

So were you able to send message successfully? If so, would you please share the exact code?

Thank you all.

Yes I can. And I've notice that I must add NotificationPayload class to the template then I got a new notif appear on my device. I'm AFK right now, ill reply my template when I'm at home.

@arhen @amercobra
I can confirm, the library works great for me. So I suspect, there is something wrong in your setup. Things to check:

  1. Is FCM sender id and server key correct? Go here https://console.firebase.google.com/project/ find your project, then click on the gear icon (left right corner), go to Project Settings -> Cloud Messaging tab.
  2. Is the payload correct? Check the README.md documentation and https://firebase.google.com/docs/cloud-messaging/concept-options#notifications
  3. Make sure you use FCM and not GCM in your Android app, also make sure everything is properly configured in manifest and in code.
  4. Android app: read logcat, it will help you troubleshoot the issue. Maybe notification gets received but no alert pops-up on the screen.
  5. This library is only good for .NET Core 3.1 and beyond. If you use .NET Core 2.2 or .NET Framework 4.7 - you might run into issues.