Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apns payload message json format directly shown

we have implemented apple apns push notification. Configured pem file and device tokens in python. They trigger json payload like this

{"aps" : { "alert" : "got 1 new offer. To view, please tap here." },"notification_type":"New Offer history","redirect_link”:”offers”}.

we got notification, but the full json shows in message. we need to display only alert message only on notification message

like image 796
Elavarasan Avatar asked Sep 12 '25 18:09

Elavarasan


1 Answers

I think for notification to display data instead of json in push try below json

{
   "aps":{
      "alert":"This is your message to be displayed",
      "sound":"default",
      "badge":1
    }, 
   "Data":{"key1":"val1", "key2":"val2"}
}

The alert content will be displayed in push and the Data Key/Val pairs is your custom data that you can pass in payload and access it in your code.

The code shared above is the working code I have used in most of my API projects.

like image 74
Mohammad Sharaf Ali Avatar answered Sep 14 '25 07:09

Mohammad Sharaf Ali