passkit - PKPASS not opennig in Passbook -
i'm new passbook. created web application using php-pkpass library create passes passbook. used necessary licences. when submit create form, creates pass, pass doesn't work on passbook. if send email attachment, shows null. works fine on android. i'm on windows pc can't use iphone simulator view logs. here link pass created me - http://tanvir.tennisads.com/passbook/passes/pass-36252.pkpass
can please me identify what's wrong pass? in advance.
update: i've removed beacons , location part, having same issue. here generated json code.
{ "description": "kenedy store", "formatversion": 1, "organizationname": "kenedy store", "passtypeidentifier": "pass.com.retailness.testing.passbook", "serialnumber": "449925", "teamidentifier": "nbn8h8w46l", "coupon": { "primaryfields": [ { "key": "offer", "label": "any purchase", "value": "25% off" } ], "auxiliaryfields": [ { "key": "expires", "label": "expires", "value": "30-06-2015" } ], "backfields": [ { "key": "terms", "label": "terms , conditions", "value": "tos" } ] }, "backgroundcolor": "rgb(255,255,255)", "foregroundcolor": "rgb(15, 15, 15)", "labelcolor": "rgb(85, 85, 85)", "logotext": "kenedy store" }
here php code used create pass...
<html> <head> <title>passbook demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="styles/bootstrap.min.css"> <link rel="stylesheet" href="styles/smoke.min.css"> <link rel="stylesheet" href="styles/custom.css"> <script src='scripts/jquery.min.js'></script> <script src='scripts/bootstrap.min.js'></script> <script src='scripts/smoke.min.js'></script> </head> <body> <?php function randomstring($length) { $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; $randstring = ''; ($i = 0; $i < $length; $i++) { $randstring .= $characters[rand(0, strlen($characters))]; } return $randstring; } $flag = false; $name = urldecode($_post['name']); $amount = urldecode($_post['amount']); $message = urldecode($_post['message']); $expires = urldecode($_post['expires']); $email = urldecode($_post['email']); $uuid = urldecode($_post['uuid']); $major = urldecode($_post['major']); $minor = urldecode($_post['minor']); $tos = urldecode($_post['tos']); $appurl = urldecode($_post['appurl']); $lat = urldecode($_post['lat']); $lon = urldecode($_post['lon']); $beacon_msg = urldecode($_post['beacon_msg']); $location_msg = urldecode($_post['location_msg']); $target = ""; if($_files['file']['name']){ $flag = true; $file = $_files['file']; $n = $file['name']; $ext = end((explode(".", $n))); $target = "images/up/logo." .$ext; move_uploaded_file($file['tmp_name'], $target); } require 'includes/pkpass/pkpass.php'; $pass = new pkpass\pkpass(); $pass->setcertificate('certificates/certificate.p12'); $pass->setcertificatepassword('tanvir123'); $pass->setwwdrcertpath('certificates/applewwdrca.pem'); $standardkeys = array( 'description' => "{$name}", 'formatversion' => 1, 'organizationname' => "{$name}", 'passtypeidentifier' => 'pass.com.retailness.testing.passbook', // 4. set yours 'serialnumber' => randomstring(6), //change randomize 'teamidentifier' => 'nbn8h8w46l' ); $associatedappkeys = array( ); $relevancekeys = array( ); $stylekeys = array( 'coupon' => array( 'primaryfields' => array( array( 'key' => 'offer', 'label' => "{$message}", 'value' => "{$amount}% off" ) ), 'auxiliaryfields' => array( array( 'key' => 'expires', 'label' => 'expires', 'value' => "{$expires}" ) ), 'backfields' => array( array( 'key' => 'terms', 'label' => 'terms , conditions', 'value' => "{$tos}" ) ) ) ); $visualappearancekeys = array( 'backgroundcolor' => 'rgb(255,255,255)', 'foregroundcolor' => 'rgb(15, 15, 15)', 'labelcolor' => 'rgb(85, 85, 85)', 'logotext' => "{$name}" ); $webservicekeys = array(); // merge pass data , set json $pass object $passdata = array_merge( $standardkeys, $associatedappkeys, $relevancekeys, $stylekeys, $visualappearancekeys, $webservicekeys ); $pass->setjson(json_encode($passdata)); // add files pkpass package $pass->addfile('images/icon.png'); $pass->addfile('images/icon@2x.png'); if($flag == false) $pass->addfile('images/logo.png'); else $pass->addfile($target); $pass->addfile($target); $data = $pass->create(true); $path = 'passes/pass-'.randomstring(5).'.pkpass'; file_put_contents($path, $data); //unlink($new_file_path); $fullpath = 'http://' . $_server['server_name'] . '/passbook/' . $path; ?> <div class="container"> <div class="row"> <div class="col-md-12"> <div class="col-md-2"> <img src="images/logo.png" height="93" width="156" alt=""> </div> <div class="col-md-10 text-center"> <h2>passbook / ibeacon demo</h2> </div> </div> </div> <div class="col-md-6 col-md-offset-3 text-center"> <a href="<?php echo $fullpath; ?>">download</a> pass.<br> or use qr code instead: <br> <?php require 'includes/phpqrcode/qrlib.php'; qrcode::png($fullpath, $path . '.png'); ?> <img src="<?php echo $path . '.png'; ?>" width=500> </div> </div> </body> </html>
and here screenshot of what's hapenning when try download pass iphone: http://i.imgur.com/5nlal3g.jpg
looking @ pass.json
can see 2 errors.
"beacons": [{ "proximityuuid": "", "relevanttext": "", "major": "0", "minor": "0" }], "locations": [{ "longitude": "90.42607140943142", "latitude": "23.7636902410487", "relevanttext": "office" }],
the first error beacons dictionary contains invalid entry. have not supplied proximityuuid
or relevanttext
.
the second error being caught xcode.
jun 10 09:09:02 pfr mobilesafari[4660] <warning>: invalid data error reading pass pass.com.retailness.testing.passbook/314548. value key 'latitude' must of class nsnumber, of class __nscfstring.
you providing latitude , longitude values strings when need provided decimals.
drop beacons array , quotes around lat , long values , should ok.
update
your new pass fine. not loading on phone because web server not applying content-type
header , therefore ios not recognise file pass.
http/1.1 200 ok date: fri, 12 jun 2015 17:25:58 gmt server: apache last-modified: thu, 11 jun 2015 07:44:56 gmt accept-ranges: bytes content-length: 20604
add content-type: application/vnd.apple.pkpass
header file , should find loads ok.
for more info on how add header, see answers this question.
Comments
Post a Comment