Reputation: 41
I need to create a service for sending notifications for my own card in the applet vallet but I have problems. My card is registered and a push token arrives at my service, but when I try to send a notification for this token to the device. I get a message but the message does not arrive on the device itself.
STEP 1. I sign my «apple wallet card» with two certificates.
Commands
openssl pkcs12 -in certificate.p12 -clcerts -nokeys -out passcertificate.pem -passin pass: <password>
openssl pkcs12 -in certificate.p12 -nocerts -out passkey.pem -passin pass:<password> -passout pass: <new password>
openssl smime -binary -sign -certfile WWDR.pem -signer passcertificate.pem -inkey passkey.pem -in manifest.json -out signature -outform DER -passin pass: <new password>
zip -r nameOfPass.pkpass manifest.json pass.json signature logo.png icon.png [email protected] strip.png [email protected]
and the card is created successfully
{
"formatVersion" : 1,
"passTypeIdentifier" : {pass identifier},
"serialNumber" : "p69f2J",
"teamIdentifier" : {team id},
"webServiceURL" : {hooke to server},
"authenticationToken" : "vxwxd7J8AlNNFPS8k0a0FfUFtq0ewzFdc",
"locations" : [
{
"longitude" : -122.3748889,
"latitude" : 37.6189722
}
],
"barcode" : {
"message" : "123456789",
"format" : "PKBarcodeFormatPDF417",
"messageEncoding" : "iso-8859-1"
},
"organizationName" : "Maxbonus",
"description" : "test utils",
"logoText" : "Organic Produce",
"foregroundColor" : "rgb(0, 0, 0)",
"backgroundColor" : "rgb(220,20,60)",
"secondaryFields": [
{
"key": "name",
"label": "Name",
"changeMessage": "Your name was updated"
}
],
"storeCard" : {
"primaryFields" : [
{
"key" : "bonuses",
"label" : "bonuse",
"value" : 21.75,
"changeMessage" : "Bonuses changed to %@."
}
],
"auxiliaryFields" : [
{
"key" : "deal",
"label" : "Maxbonus",
"value" : "cards"
}
]
}
}
STEP 2.
For my server I use nodejs and package node-apn.
var options = {
cert: "cert/passcertificate.pem",
key: "cert/passkey.pem",
passphrase:"12345",
production: true
};
var apnProvider = new apn.Provider(options);
var note = new apn.Notification();
var deviceToken = "bbb9929f8489fec538675888766352a595fc67e202090fa4e8f8f17cb273026c";
note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.
note.badge = 1;
note.sound = "ping.aiff";
note.alert = "WHAT";
note.payload = {'bonuses': 'Solog'};
note.topic = {pass identifier};
console.log(`Sending: ${note.compile()} to ${deviceToken}`);
console.log('NOTE', note)
apnProvider.send(note, deviceToken).then( (result) => {
// see documentation for an explanation of result
console.log('result', result)
if(result.failed[0]) {
console.log(result.failed[0].response)
}
});
Console result: result
but when I want to send my notification, it does not come to the phone.
Upvotes: 4
Views: 1351