-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Push notification stopped working in V5 with badge: 1 or Increment #8118
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
Comments
Thanks for opening this issue!
|
The issue may be related to the version of the push adapter. Did you compare the different versions of the adapter in both parse server versions? |
Thanks for your answer. When I run npm i for Parse Server 5.4.2, it installs directly the old push-adapter 3.4.1. Even if I add "@parse/push-adapter": "^4.1.2" in the package.json, it installs the push-adapter 4.1.0 for Parse Server 5.4.2. It still have the same error. When I search for "badge" in @parse/push-adapter, it doesn't look related to the push-adapter, but to Parse Server itself. I'm pretty sure the error comes from this file
Without the badge parameter, it does not enter the badgeUpdate which makes a Write operation. This Write operation is the source of the log error I think. For some reason, Webstorm does not let me break in this file. |
I do not really understand how this function works
If I comment the writing part (in the parse-server/lib/Controllers/PushController.js), I now receive the notification.
Hence the problem must come from this write function. Maybe I should update my MongoDB from 4.4 to 5. |
Is the Push controller logic that different between Parse Server 4.x and 5.x? I can't remember there being any major changes. |
I found the origin of the problem. The Push controller hasn't changed since 2020. Actually, the change comes from RestWrite.js: https://github.com/parse-community/parse-server/blob/alpha/src/RestWrite.js When I break in the code, it fails in this.config.database.update(this.className, this.query, this.data, this.runOptions, false, false, this.validSchemaController) The this.data has changed in RestWrite.prototype.execute in Parse 5. At the beginning of the execution,
When it goes to this.runBeforeSaveTrigger(), Parse 5 includes a property "objectId": undefined, when it was not set in Parse 4.
In Parse 4, I got
Then in this.setRequiredFieldsIfNeeded(), it adds the "updatedAt" property but it does not have an impact on the error.
The error given by MongoDB definitely come from the "objectId": undefined I've seen that RestWrite had few commits in the last few months and the change must come from one of them. Do you have an easy way to see the changes in RestWrite.prototype.runBeforeSaveTrigger since Parse 4 ? |
Well investigated! Would you mind opening a PR with a filing test that reproduces this issue?
Several ways, if you use VSC for example you could simply compare between different commits, see docs. You can also compare between commits directly on GitHub, or just jump to the file and look at the git blame context. |
Thanks, I spent some time to add the test, but I didn't manage to break in this given test to see if it fails or not, and what the different states are inside this test. I take a week off, I'll try again in 10 days. I think this is the failing test, but haven't manage to test it yet.
|
You could just look at the existing tests and rewrite a test that already comes close to what you want to test. Take a look at the |
New Issue Checklist
Issue Description
Push notification with badge stopped working after 5.0.0, it worked up to 4.10.13.
I send push notification with the following code:
with pushQuery the result from the _Installation table and data:
If I replace 1 by "Increment" also in the documentation, it also fails.
"badge": "Increment"
The only solution which works is to remove the property badge. In this case, I do receive the notifications. It means it's nor a SDK problem or push parameters, but a problem with this badge parameter.
This JSON DO works:
Steps to reproduce
Send a notification with the data properties and valid Installations.
Notifications should be received without "badge" properties, but not received with "badge" parameter set at 1 or "Increment". Is it still supported in 5.0 Parse Server version and above?
Actual Outcome
I do not receive any notification on my iOS and Android apps
The server (both in local and production) gives the following error:
For
"badge": "Increment"
, I have the exact same error but with different input/result:Expected Outcome
I expect to receive notifications.
If I remove in the JSON called data the property badge, it works and I DO receive notifications:
In this case, beforeSave for _Installation is not triggered.
The error must come from this _Installation objects update.
Environment
Server
5.2.4
Ubuntu
Remote
I also reproduce it on my macOS 12.5 in local, connected to the MondoDB Atlas database
Database
MongoDB
4.4.15
MongoDB Atlas
Client
iOS
1.19.3
Logs
The text was updated successfully, but these errors were encountered: