Axon
Axon

Reputation: 69

Invalid parameter: JSON must contain an entry for 'default' or 'APNS_SANDBOX'. => APNS Error in Scala (lift framework)

I'm getting APN Invalid parameter: JSON must contain an entry for 'default' or 'APNS_SANDBOX'. the log is here

enter image description here

And the code block is here:

enter image description here

how to fix this? this is built in scala lift framework.

Upvotes: 1

Views: 1886

Answers (1)

Abhay Pratap
Abhay Pratap

Reputation: 1986

This is the example in javascript. In the same way, we have to use. Need to use cases for 1.APNS_SANDBOX 2.APNS 3.default

  // Setup SNS Client
const snsClient = new SNS();
// whatever your full endpoint arn is. (from createPlatformEndpoint)
const endpointArn = 'arn:aws:sns:...';
// any extra data you want passed along with the message
const payload = {
  someCustomKey: 'someCustomValue'
};
// send it
snsClient.publish({
  TargetArn: endpointArn,
  MessageStructure: 'json', // so we can put in a custom payload and message
  Message: JSON.stringify({
    default: `DEFAULT MESSAGE ${message}`,
    APNS_SANDBOX: JSON.stringify({
      aps: {
        alert: `IOS Sandbox SPECIFIC MESSAGE ${message}`,
      },
      payload,
    }),
    APNS: JSON.stringify({
      aps: {
        alert: `IOS Prod SPECIFIC MESSAGE ${message}`,
      },
      payload,
    }),
  }),
  }).promise().then(() => {
   console.log('Notification sent!');
  }).catch((err) => {
   console.log('Failed to send with:', err);
  });

Used this link for reference

Upvotes: 2

Related Questions