Skip to content

Instantly share code, notes, and snippets.

@nfhipona
Last active January 20, 2021 04:10
Show Gist options
  • Save nfhipona/f34e6455d48aeda6c9476eac507fa729 to your computer and use it in GitHub Desktop.
Save nfhipona/f34e6455d48aeda6c9476eac507fa729 to your computer and use it in GitHub Desktop.
[APNs Authentication Key] FCM Test PUSH Script for debugging
#!/bin/bash
# https://firebase.googleblog.com/2017/01/debugging-firebase-cloud-messaging-on.html
# https://firebase.google.com/docs/cloud-messaging/http-server-ref#notification-payload-support
# https://firebase.google.com/docs/cloud-messaging/http-server-ref
# https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1
clear
echo
echo "------ Debug start ------"
echo
SERVER_KEY="YOUR_FCM_SERVER_KEY"
ENDPOINT=https://fcm.googleapis.com/fcm/send
read -r -d '' payload <<-'EOF'
{
"notification": {
"title": "Hello from FCM!",
"body": "Hello from curl via FCM!",
"sound": "default",
"badge": 12,
"click_action": "redirect-to-myorders",
"subtitle": "FCM subtitle"
},
"data": {
"customKey": "Custom values here",
"customKey2": "Custom values2 here"
},
"content_available": true,
"priority": "high",
"to": "YOUR_FIREBASE_REGISTRATION_TOKEN"
}
EOF
# --------------------------------------------------------------------------
curl --verbose \
--header "content-type: application/json" \
--header "authorization: key=$SERVER_KEY" \
--data "${payload}" \
$ENDPOINT
echo
echo "------ Debug end ------"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment