Skip to content

Instantly share code, notes, and snippets.

@sugaith
Last active December 9, 2025 16:40
Show Gist options
  • Select an option

  • Save sugaith/e22d5a55836eddef2a4a56ffe01a412d to your computer and use it in GitHub Desktop.

Select an option

Save sugaith/e22d5a55836eddef2a4a56ffe01a412d to your computer and use it in GitHub Desktop.
sh Script to send APN TO A DEVICE - Apple Push Notification
export APNS_KEY_ID="U8U48-----"
export APNS_TEAM_ID="Z2N42-----"
export APNS_KEY=$(cat << 'EOF'
-----BEGIN PRIVATE KEY-----
<...THE APN KEY CONTENT HERE...>
-----END PRIVATE KEY-----
EOF
)
mkdir -p ~/apns-jwt && cd ~/apns-jwt
npm init -y >/dev/null 2>&1
npm i jsonwebtoken@9 --silent
export APNS_JWT=$(node -e 'const jwt=require("jsonwebtoken");const key=process.env.APNS_KEY;process.stdout.write(jwt.sign({iss:process.env.APNS_TEAM_ID},key,{algorithm:"ES256",header:{kid:process.env.APNS_KEY_ID}}));')
export VOIP_TOKEN="<VOIP_TOKEN>"
export BUNDLE_ID="io.conquer.mobile.development"
curl -v --http2 \
-H "authorization: bearer $APNS_JWT" \
-H "apns-topic: ${BUNDLE_ID}.voip" \
-H "apns-push-type: voip" \
-H "apns-expiration: 0" \
-H "content-type: application/json" \
--data "{\"aps\":{\"content-available\":1},\"data\":{\"aid\":\"00DfL00000OFRbZUAX\",\"uid\":\"005fL000005Bg5DQAS\",\"inboundOid\":\"test-inbound-call\",\"connectNumber\":\"+19154072139\",\"displayName\":\"Test Inbound Call\",\"phoneNumber\":\"+19154072139\",\"companyName\":\"Conquer Widgets Inc.\",\"offerTimeoutSeconds\":45}}" \
https://api.push.apple.com/3/device/$VOIP_TOKEN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment