Hello everyone,
I'm having trouble with sending custom push notifications for Apple Wallet passes. Here's what I've done so far:
Registered a new pass: I receive a deviceToken for the pass.
Enabled Push Notifications: Push notifications for the Apple Wallet app and the specific pass are enabled on my phone.
Added the Key for Push Notifications: I've added the necessary key for push notifications.
I use following code to send the message via APNS:
const tokenKey = fs.readFileSync(options.tokenPath).toString();
jwtToken = sign({}, tokenKey, {
algorithm: 'ES256',
expiresIn: '1h',
issuer: options.teamId,
header: {
alg: 'ES256',
kid: options.keyId
}
});
const client = http2.connect('https://api.push.apple.com:443');
const notificationPayload = JSON.stringify({ aps: { "alert" : "Hello" } });
// and try
//{
// "aps": {
// "alert": "Your pass has been updated!",
// "sound": "default"
// },
// "pass-type-identifier": "pass.com.example.myPass",
// "serial-number": "123456789",
// "device-token": "<deviceToken>"
//}
const request = client.request({
':method': 'POST',
':path': `/3/device/${deviceToken}`,
'apns-topic': topicId,
'apns-push-type': 'alert',
'authorization': `bearer ${jwtToken}`,
'apns-priority': 10,
'content-type': 'application/json',
'content-length': Buffer.byteLength(notificationPayload)
});
return new Promise((resolve, reject) => {
request.on('response', (headers, flags) => {
for (const name in headers) {
console.log(`${name}: ${headers[name]}`);
}
});
request.on('data', (chunk: string) => console.log(chunk));
request.on('end', () => {
client.close();
resolve();
});
request.on('error', (err) => {
console.error('Error sending push notification:', err);
reject(err);
});
request.write(notificationPayload);
request.end();
});
When I send the message, I receive a :status:200 and a apns-ID, indicating that the message has been sent. However, I do not receive the custom push notifications on my phone. The pass updates are received without any issues, but the notifications are not.
Has anyone encountered this issue or know if it's possible to send custom push notifications for Apple Wallet passes in this manner? Any guidance on how to resolve this issue would be greatly appreciated.