简体   繁体   中英

Service Extension not called for Parse Cloud Code push notification

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';
});

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM