1

I am trying to use Cloud Code to send push notifications from Parse Server 4.2.0.

I am switching from Firebase Cloud Messaging and had implemented a service extension that changed the notification title and body based on the notification payload.

After switching to Parse Push I realised that the service extension is not called anymore.

After checking the documentation, I tried adding the mutable-content flag, which made my app crash when calling the Cloud function.

All four of the commented out flags result in a Parse server error:

Fatal error: Error calling cloud function: ParseError code=141 error=Invalid function: "pushsample"

When I comment them out, the function works and I receive a push notification on my test device.

How do I correctly set the mutable-content flag so that I can modify the notification before showing it to the user?

My Parse backend is with Back4App, and I initialise the Parse server like this (the passed variables contain the necessary information as Strings:

ParseSwift.initialize(applicationId: applicationId, clientKey: clientKey, serverURL: serverURL)

This is my Cloud Function:

Parse.Cloud.define('pushsample', async () => {
       
       Parse.Push.send({
         channels: ["channelForTesting"],
            data: {
                
                alert: 'from CloudCode',
                title: 'Hello',
                
                // content-available: 1,
                // push_type: alert,
                // priority: 10,
                // mutable-content: 1,

            }
        }, { useMasterKey: true });
      
      return 'pushsample called successfully';
});
kk94
  • 143
  • 1
  • 8
  • 1
    try `'mutable-content'` instead of `mutable-content` – Davi Macêdo Jan 24 '22 at 04:41
  • Thanks, that worked! I thought I had tried that before, but apparently I didn't do it right. If only every problem would be this easy to solve - thanks for the leg up Davi! – kk94 Jan 24 '22 at 16:20

1 Answers1

0

Kudos to Davi, it was a typo. Using 'mutable-content' solved the problem.

kk94
  • 143
  • 1
  • 8