Registry / testing / apn-test

apn-test

JSON →
library1.3.1jsnpmunverified

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.

npm install apn-test
INSTALL
IMPORT
SIG · APN-TEST
A
apn-test
testingjavascriptv1.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

apnTest
var apnTest = require('apn-test');
import apnTest from 'apn-test';
This package does not support ES modules; use CommonJS.
CLI command 'apn'
apn "Hello" --token=DEVICE_TOKEN --cert=cert.pem --key=key.pem
apn-test "Hello" --token=DEVICE_TOKEN
The CLI command is 'apn', not 'apn-test'. Install globally and run via terminal.
Default export
var apnTest = require('apn-test');
var apnTest = require('apn-test').default;
The package exports a single function directly, not as a property.

Send a test push notification to a device token using certificate and key files.

var apnTest = require('apn-test'); var message = 'Hello, iOS!'; var options = { cert: '/path/to/cert.pem', key: '/path/to/key.pem', token: 'uney4jcnvvw5bc2vlvazog4au1xa0zbcbsjwlfgaj1pi9blcdltgktncfxfwhs5' }; apnTest(message, options, function(err, response) { if (err) { console.error('Failed:', err); } else { console.log('Success:', response); } });
apn-test --version
Debug
Known issues
gotchaCLI uses 'apn' not 'apn-test' as the command name.
fix
Run CLI with `apn` instead of `apn-test`.
affects: >=0.2.0
gotchaThe 'token' option in CLI accepts a comma-separated list, but JavaScript API expects a single token string.
fix
For multiple tokens, call apnTest multiple times or use the CLI.
affects: >=0.2.0
breakingNode.js engine requirement >=0.10.0; may not work on very old or very new Node versions.
fix
Use Node >=0.10.0 and <=12.x (best effort).
affects: >=0.1.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open 'cert.pem'
Default certificate file not found; must specify path via options or CLI.
fix
Provide absolute or relative path to cert.pem via --cert option.
Error: socket hang up
APNs server connection failure due to network or invalid credentials.
fix
Check cert/key files, ensure proper permissions, verify network.
Response code: 400, body: {"reason":"BadDeviceToken"}
Provided device token is invalid or not for the selected environment.
fix
Verify token correctness and use appropriate environment (development/production).
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
54 hits · last 30 days
node
50
OpenAI (training)
1
Resources
apn-test — npm install apn-test · libregistry