{"id":24912,"library":"apn-test","title":"apn-test","description":"apn-test (v1.3.1) is a CLI tool and Node.js library to quickly send a test push notification to an iOS device via Apple Push Notification service (APNs). It simplifies testing by requiring only a device token, certificate, and key. The package supports both single and multiple device tokens, payload customization, and production/development environments. It is lightweight, with no runtime dependencies, and offers a simple API. Maintenance is low; the last release was in 2017.","status":"maintenance","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/matiassingers/apn-test","tags":["javascript","apple push notifications","ios","push notifications","apns","apn","cli"],"install":[{"cmd":"npm install apn-test","lang":"bash","label":"npm"},{"cmd":"yarn add apn-test","lang":"bash","label":"yarn"},{"cmd":"pnpm add apn-test","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package does not support ES modules; use CommonJS.","wrong":"import apnTest from 'apn-test';","symbol":"apnTest","correct":"var apnTest = require('apn-test');"},{"note":"The CLI command is 'apn', not 'apn-test'. Install globally and run via terminal.","wrong":"apn-test \"Hello\" --token=DEVICE_TOKEN","symbol":"CLI command 'apn'","correct":"apn \"Hello\" --token=DEVICE_TOKEN --cert=cert.pem --key=key.pem"},{"note":"The package exports a single function directly, not as a property.","wrong":"var apnTest = require('apn-test').default;","symbol":"Default export","correct":"var apnTest = require('apn-test');"}],"quickstart":{"code":"var apnTest = require('apn-test');\n\nvar message = 'Hello, iOS!';\nvar options = {\n  cert: '/path/to/cert.pem',\n  key: '/path/to/key.pem',\n  token: 'uney4jcnvvw5bc2vlvazog4au1xa0zbcbsjwlfgaj1pi9blcdltgktncfxfwhs5'\n};\n\napnTest(message, options, function(err, response) {\n  if (err) {\n    console.error('Failed:', err);\n  } else {\n    console.log('Success:', response);\n  }\n});","lang":"javascript","description":"Send a test push notification to a device token using certificate and key files."},"warnings":[{"fix":"Run CLI with `apn` instead of `apn-test`.","message":"CLI uses 'apn' not 'apn-test' as the command name.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"For multiple tokens, call apnTest multiple times or use the CLI.","message":"The 'token' option in CLI accepts a comma-separated list, but JavaScript API expects a single token string.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Use Node >=0.10.0 and <=12.x (best effort).","message":"Node.js engine requirement >=0.10.0; may not work on very old or very new Node versions.","severity":"breaking","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Provide absolute or relative path to cert.pem via --cert option.","cause":"Default certificate file not found; must specify path via options or CLI.","error":"Error: ENOENT: no such file or directory, open 'cert.pem'"},{"fix":"Check cert/key files, ensure proper permissions, verify network.","cause":"APNs server connection failure due to network or invalid credentials.","error":"Error: socket hang up"},{"fix":"Verify token correctness and use appropriate environment (development/production).","cause":"Provided device token is invalid or not for the selected environment.","error":"Response code: 400, body: {\"reason\":\"BadDeviceToken\"}"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}