4

我需要在 applet vallet 中为我自己的卡创建一个发送通知的服务,但我遇到了问题。我的卡已注册并且推送令牌到达我的服务,但是当我尝试将此令牌的通知发送到设备时。我收到一条消息,但消息没有到达设备本身。

步骤 1. 我用两张证书签署了我的 «apple wallet card»。

命令

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 icon@2x.png strip.png strip@2x.png

并且卡片创建成功

我的苹果钱包卡

{
  "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"
      }
    ]
  }
}

第2步。

对于我的服务器,我使用 nodejs 和包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)
            }
        });

控制台结果:结果

但是当我想发送通知时,它不会发送到手机。

4

0 回答 0