tschoffelen / php-pkpass

💳 PHP class for creating passes for Wallet on iOS.
https://includable.com
MIT License
901 stars 185 forks source link

How do I update a pass ? #106

Closed haiworler closed 3 years ago

haiworler commented 3 years ago

I don’t know how I can update a pass to get the client’s iphone push token, and then send notifications.

tschoffelen commented 3 years ago

You will need to provide a couple of HTTP endpoints to implement this functionality.

Some tips/starting points:

  1. Read the conceptual guide about Updating passes
  2. Set a webServiceURL in your pass JSON
  3. Implement a web service following the Web Service Reference
haiworler commented 3 years ago

Hello, and Thank you for the prompt response, On this topic I have been researching and still do not understand how the process is, to receive by the web service the push token of the phone. this is my code.

$data = [ 'description' => 'Name', 'formatVersion' => 1, 'organizationName' => 'Flight Express', 'passTypeIdentifier' => 'pass.com.example', // Change this! 'serialNumber' => $serialNumber, 'teamIdentifier' => '589F9Z9FP3', // Change this! "webServiceURL" => "https://example/api/registerPasskit", "authenticationToken" => $authenticationToken, 'boardingPass' => [ 'primaryFields' => [ [ 'key' => 'origin', 'label' => 'San Francisco', 'value' => 'SFO', ], [ 'key' => 'destination', 'label' => 'London', 'value' => 'LHR', ], ], 'secondaryFields' => [ [ 'key' => 'gate', 'label' => 'Gate', 'value' => 'F12', ], [ 'key' => 'date', 'label' => 'Departure date', 'value' => "2021-04-09T05:00-07:00", ], ], 'backFields' => [ [ 'key' => 'passenger-name', 'label' => 'Passenger', 'value' => 'Cuarta prueba v4', ], [ "changeMessage" => "%@", "label" => " ", "value" => "I will change this soon", "key" => "fieldToChange" ] ], 'transitType' => 'PKTransitTypeAir', ], 'barcode' => [ 'format' => 'PKBarcodeFormatQR', 'message' => 'Flight-GateF12-ID6643679AH7B', 'messageEncoding' => 'iso-8859-1', ], 'backgroundColor' => 'rgb(32,110,247)', 'logoText' => 'Colombia', 'relevantDate' => "2021-04-09T05:00-07:00" ]; $pass->setData($data);

    // Add files to the pass package
    $pass->addFile(base_path('public/images/icon.png'));
    $pass->addFile(base_path('public/images/logo.png'));
    $pkpass = $pass->create();

I already created the pass with the url of the web service post type. But I don’t know when I should get the push token of the iphone. If it is when the customer gives you to add pass to the wallet or if I have to do an additional process. I also don’t know if I need to enable something in my Apple account when creating the pass type ID. I would be grateful for any assistance in respect of these matters.