Skip to content

Push notification stopped working in V5 with badge: 1 or Increment #8118

Closed
@ga262

Description

@ga262

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:

const result = await Parse.Push.send({
    where: pushQuery,
    data: data
}, {useMasterKey: true});

with pushQuery the result from the _Installation table and data:

const data = {
    "title": "title",
    "body": "message",
    "type": "type",
    "alert": {"title": "title", "body": "message"},
    "badge": 1,
    "priority": 10,
    "push_type": "alert"
};

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:

const data = {
    "title": "title",
    "body": "message",
    "type": "type",
    "alert": {"title": "title", "body": "message"},
    "priority": 10,
    "push_type": "alert"
};

Steps to reproduce

Send a notification with the data properties and valid Installations.

const pushQuery = Installation.getInstallationQueryForUsers(users);  
const data = {
    "title": "title",
    "body": "message",
    "type": "type",
    "alert": {"title": "title", "body": "message"},
    "badge": 1,
    "priority": 10,
    "push_type": "alert"
};
const result = await Parse.Push.send({
    where: pushQuery,
    data: data
}, {useMasterKey: true});

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:

info: beforeSave triggered for _Installation for user undefined:
Input: {"badge":1}
Result: {"object":{"badge":1}} {"className":"_Installation","triggerType":"beforeSave"}

error: _PushStatus AuJRwiG9Nq: error while sending push Performing an update on the path '_id' would modify the immutable field '_id' {"code":66,"index":0,"stack":"MongoServerError: Performing an update on the path '_id' would modify the immutable field '_id'\n    at /home/node_modules/mongodb/lib/operations/update.js:110:33\n    at /home/node_modules/mongodb/lib/cmap/connection_pool.js:273:25\n    at handleOperationResult (/home/node_modules/mongodb/lib/sdam/server.js:363:9)\n    at MessageStream.messageHandler (/home/node_modules/mongodb/lib/cmap/connection.js:474:9)\n    at MessageStream.emit (events.js:375:28)\n    at MessageStream.emit (domain.js:470:12)\n    at processIncomingData (/home/node_modules/mongodb/lib/cmap/message_stream.js:108:16)\n    at MessageStream._write (/home/node_modules/mongodb/lib/cmap/message_stream.js:28:9)\n    at writeOrBuffer (internal/streams/writable.js:358:12)\n    at MessageStream.Writable.write (internal/streams/writable.js:303:10)\n    at TLSSocket.ondata (internal/streams/readable.js:726:22)\n    at TLSSocket.emit (events.js:375:28)\n    at TLSSocket.emit (domain.js:470:12)\n    at addChunk (internal/streams/readable.js:290:12)\n    at readableAddChunk (internal/streams/readable.js:265:9)\n    at TLSSocket.Readable.push (internal/streams/readable.js:204:10)"}

For "badge": "Increment", I have the exact same error but with different input/result:

info: beforeSave triggered for _Installation for user undefined:
Input: {"badge":{"__op":"Increment","amount":1}}
Result: {"object":{"badge":{"__op":"Increment","amount":1}}} {"className":"_Installation","triggerType":"beforeSave"}

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

  • Parse Server version: 5.2.4
  • Operating system: Ubuntu
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Remote
    I also reproduce it on my macOS 12.5 in local, connected to the MondoDB Atlas database

Database

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

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): iOS
  • SDK version: 1.19.3

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions