Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to get notification using fcm http v1 api ,from parse dashboard it is showing successful pushes #269

Open
4 tasks
mrutyunjaypowerschool opened this issue Jul 10, 2024 · 6 comments
Labels

Comments

@mrutyunjaypowerschool
Copy link

New Issue Checklist

Issue Description

Steps to reproduce

Actual Outcome

Expected Outcome

should send notification to device

Environment

Client

  • Parse Server Push Adapter version: Parse server:3.9.0,parse-push-adapter:5.2.0

Server

  • Parse Server version: 3.9.0,
  • Operating system: mac
  • Local or remote host-local andAWS

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 7
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): local

Logs

No error showing

Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@mtrezza
Copy link
Member

mtrezza commented Jul 11, 2024

Could you add more details to the issue description please. Did you setup ever send successful pushes, and if yes, with which push adapter version?

@massivespace
Copy link

massivespace commented Oct 11, 2024

We are in the process of upgrading from parse server 2.x to 6.x, and were experiencing the same issue with Android. I narrowed it down to a schema change. We were sending push notifications in parse cloud code as follows (this is how we have been configured since 2014 or so):

        await Parse.Push.send(
          {
            channels: validChannels,
            data:     {
              alert: "welcome message",
              badge: 0,
              sound: 'default',
            },
          },
          { useMasterKey: true }
        );

Off the bat, after updating to parse server 6, the badge:0 line was getting rejected with the error:
ERR! parse-server-push-adapter FCM error sending push: Error: data must only contain string values
After some experimentation, I found that this goes away after installing the parse-push-adapter separately and invoking a new ParsePushAdapter() call in the parse startup config. We are running parse server 6.5.8, which to my understanding should have support for the old GCM deprecation and new FCM migration. However, the newer push adapter seems to allow this for the badge, which I believe iOS needs, or at least allows, so it was throwing us off because iOS was working.

Our client is an Ionic React app, and we are using the @capacitor/push-notifications plugin. The notifications were coming in, but the capacitor plugin was ignoring them, because they do not have the expected payload. After some research, I found that the payload schema must have changed and needs to be accounted for with the migration from legacy to v1 FCM. While there appears to be a schema change in firebase notifications, it doesn't appear related to this. I'm assuming the original parse schema of "data -> alert, badge, sound" were not consistent with GCM and were maybe a proxy?

Specifically, the capacitor plugin expects the payload to look something like this:

{
    notification: {
        title: "title",
        body: "body",
    },
    data: {
        customPayloadField1: "mustbestring",
        customPayloadField2: "anotherstring",
    }
}

So the solution is to add that to the payload. I'm not sure where the badge fits into all of this. You can likely leave it in the data payload along with the alert and sound fields if required, but just add the notification field.

I don't think this is a bug in the push adapter (maybe the bug was that the old one had a non-standard schema, but again I'm not sure), although the "string" error I mentioned above might be worth looking into on the parse server 6 line.

@jimnor0xF
Copy link
Contributor

jimnor0xF commented Dec 12, 2024

Off the bat, after updating to parse server 6, the badge:0 line was getting rejected with the error: ERR! parse-server-push-adapter FCM error sending push: Error: data must only contain string values After some experimentation, I found that this goes away after installing the parse-push-adapter separately and invoking a new ParsePushAdapter() call in the parse startup config. We are running parse server 6.5.8, which to my understanding should have support for the old GCM

@mtrezza
Not really familiar with how Parse Server bundles adapters. Does Parse Server 6.5.8 not bundle the latest push adapter? I believe above bug was fixed in 6.1.1 of the push adapter.

@massivespace

Our client is an Ionic React app, and we are using the @capacitor/push-notifications plugin. The notifications were coming in, but the capacitor plugin was ignoring them, because they do not have the expected payload.
I'm assuming the original parse schema of "data -> alert, badge, sound" were not consistent with GCM and were maybe a proxy?

Your assumption is correct. Parse has its own payload abstraction for payloads around Android/iOS push notifications which convert to the raw payload FCM expects. Although it is somewhat loosely defined at the moment as things have evolved over the years so it can be quite confusing.

If you handle push notifications using a client SDK that is Parse-related (e.g. Parse Android SDK), notifications will pop up when you only use the data field and put alert in there.

This is not the case for non-Parse related libraries that use FCM as a provider such as @capacitor/push-notifications. These libs handle things in the "FCM-way", where you use the notification key for the alert that should pop up in the tray, and data for data payloads.

As you noticed, adding the notification key does work, since we have support for that key as well. Although documentation on the net around setting up Parse push notifications only mention the data key being the way of having a notification show up in the tray (since this is how you do things with the Parse Android/iOS SDK, historically).

There is some related discussion around improving things around this in #286.

@mman
Copy link
Contributor

mman commented Dec 12, 2024

@jimnor0xF In your deployment try this to figure out what push adapter version was pulled in. For 6.x chances are that it's the old version without the fixes.

€ npm ls @parse/push-adapter
...

@mtrezza
Copy link
Member

mtrezza commented Dec 12, 2024

Not really familiar with how Parse Server bundles adapters. Does Parse Server 6.5.8 not bundle the latest push adapter? I believe above bug was fixed in 6.1.1 of the push adapter.

Parse Server 6.5.8 comes bundled with push adapter 5.1.1, as you can see here. We don't make any particular effort to always keep Parse Server bundled with the adapter latest version, since one can easily replace the bundled adapter. The updates are automatically done by Snyk, and we can't predict when Snyk opens a PR to upgrade the adapter, but as long as there is no security issue I believe these PRs are not prioritized and can take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants