Create pass for passbook in php -


im trying create dynamically coupons app. have php server create them. don't know why doesn't work on passbook.

if create pass terminal works fine. in php php-pkpass.

i left code in php below appear in computer pass doesn't add passbook (also if send via e-mail)

im 100% sure passtypeidentifier, teamidentifier, certificate , wwdr 100% correctly

note: images exists

<?php include ("conexion.php"); require('passpk/pkpass.php');  if (isset($_get['cupon']) , $_get['cupon'] != '' , $_get['cupon'] > 0) {      $cuponid = $_get['cupon'];       $pass = new pkpass\pkpass();      $pass->setcertificate('./certificate.p12');  // 2. set path pass certificate (.p12 file)     $pass->setcertificatepassword('*******');     // 2. set password certificate     $pass->setwwdrcertpath('./wwdr.pem'); // 3. set path wwdr intermediate certificate (.pem file)       // top-level keys http://developer.apple.com/library/ios/#documentation/userexperience/reference/passkit_bundle/chapters/toplevel.html     $standardkeys         = array(         'description'        => 'store',         'formatversion'      => 1,         'organizationname'   => 'store',         'passtypeidentifier' => 'pass.store.store', // 4. set yours         'serialnumber'       => $cupon['id'],         'teamidentifier'     => '********'           // 4. set yours     );     $associatedappkeys    = array();     $relevancekeys        = array();     $stylekeys            = array(         'coupon' => array(             'primaryfields' => array(                 array(                     'key'   => 'key',                     'label' => "label"                 )             ),             'secondaryfields' => array(                 array(                     'key'   => 'name',                     'label' => 'tienda',                     'value' => "name"                 ),                 array(                     'key'   => 'date',                     'label' => 'válido hasta',                     'value' => "vigencia"                 )             ),             'backfields' => array(                 array(                     'key'   => 'tienda',                     'label' => 'tienda',                     'value' => "tienda"                 ),                 array(                     'key'   => 'sucursales',                     'label' => 'sucursales',                     'value' => 'valido en las sucursales y sus horarios'                 ),                 array(                     'key'   => 'description',                     'label' => 'descripción',                     'value' => "descr"                 ),                 array(                     'key'   => 'terms',                     'label' => 'términos y condiciones',                     'value' => "cupon"                 )             )         )     );     $visualappearancekeys = array(         'barcode'         => array(             'format'          => 'pkbarcodeformatpdf417',             'message'         => "cupon",             'messageencoding' => 'iso-8859-1'         ),         'foregroundcolor' => 'rgb(255, 255, 255)',         'backgroundcolor' => 'rgb(4, 148, 203)',         'logotext'        => 'cupon'     );     $webservicekeys       = array();      // merge pass data , set json $pass object     $passdata = array_merge(         $standardkeys,         $associatedappkeys,         $relevancekeys,         $stylekeys,         $visualappearancekeys,         $webservicekeys     );      $pass->setjson(json_encode($passdata));      //creating temp file called strip.png     //generamos un directorio temporal y creamos el strip     $uniqid = uniqid('', true);     $dir = './tempdir/'.$uniqid;     mkdir($dir, 0777);      //copiamos el archvio al nuevo directorio     copy('../'.$img, './tempdir/'.$uniqid.'/strip.png');      // add files pkpass package     $pass->addfile($dir.'/strip.png');     $pass->addfile('images/icon.png');     $pass->addfile('images/icon@2x.png');     $pass->addfile('images/logo.png');     $pass->addfile('images/logo@2x.png');      if(!$pass->create(true)) { // create , output pkpass         echo 'error: '.$pass->geterror();     }      //borramos el folder temp     unlink($dir.'/strip.png');     rmdir($dir); } 

looking @ console output attempted install pass, see following warning.

mar 25 10:45:40 iphone mobilesafari[279] <warning>: invalid data error reading pass pass.cuponice.cuponice/9. pass dictionary must contain key 'value'. mar 25 10:45:40 iphone mobilesafari[279] <warning>: passbook pass download failed: pass cannot read because isn't valid. 

digging pass.json, see primaryfields dictionary not contain 'value' key.

    "primaryfields": [{             "key": "key",             "label": "30% de descuento en persianas"         }     ], 

to fix, change php add value key primaryfields dictionary.

$stylekeys = array(     'coupon' => array(         'primaryfields' => array(             array(                 'key'   => 'key',                 'label' => "label",                 'value' => ""             )         ),                            //... 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -