Skip to content

Instantly share code, notes, and snippets.

@nishith-pubnub
nishith-pubnub / push-apns2.txt
Last active February 8, 2021 18:44
This function code adds APNs2 attributes to the publish message so clients don't have to make changes on the app to modify the payload format. The function should be setup with the before-publish trigger to modify the payload before the message is published.
export default (request) => {
try {
if ('pn_apns' in request.message) {
request.message.pn_apns.pn_push = [{
"push_type": "alert",
"auth_method": "token",
"targets": [{
"environment": "production", //set to "development" or "production"
"topic": "BUNDLE_ID" //set to the bundle id for your app
}],