How to set MIME type of application/vnd.apple.pkpass in order to share pass by link or email
Apache
Add the following line to either:
- the
.htaccess
in the directory serving your .pkpass, or - to the
mime.types
file, or - to your appache
httpd.conf
or virtuatl server.conf
file
Then restart Apache (not required if adding to .htaccess
)
AddType application/vnd.apple.pkpass pkpass
nginx
Add the following line to your mime.types
file and restart nginx
application/vnd.apple.pkpass pkpass;
IIS
- Open IIS Manager and navigate to the level you want to manage.
- In Features View, double-click MIME Types.
- In the Actions pane, click Add.
- In the Add MIME Type
.pkpass
- Type
application.vnd.pkpass
n the MIME text box - Click OK
- Restart IIS
If you are serving your file via a script and are not able to edit your web server config you could add the following line before any content is sent:
PHP
header('Content-Type: application/vnd.apple.pkpass');
C#
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/vnd.apple.pkpass");
How to share pass via email
By using Mail.app, now I can send a pass to others to add to passbook !
Passbook application/vnd.apple.pkpass mime type is not recognized
try to add a filename like this:
return File(generatedPass, "application/vnd.apple.pkpass", "my-file-name.pkpass")
Apple PassKit Wallet download link on website
You need to set the MIME type to application/vnd.apple.pkpass
for iOS to recognise the file as a pass and to open Wallet.
See this question for how to do that.
PKPASS not opennig in Passbook
Looking at your pass.json
I can see two errors.
"beacons": [{
"proximityUUID": "",
"relevantText": "",
"major": "0",
"minor": "0"
}],
"locations": [{
"longitude": "90.42607140943142",
"latitude": "23.7636902410487",
"relevantText": "office"
}],
The first error is that your beacons dictionary contains an invalid entry. You have not supplied a proximityUUID
or relevantText
.
The second error is being caught by Xcode.
Jun 10 09:09:02 pfr MobileSafari[4660] <Warning>: Invalid data error reading pass pass.com.retailness.testing.passbook/314548. Value for key 'latitude' must be of class NSNumber, but is actually of class __NSCFString.
You are providing your latitude and longitude values as strings when they need to be provided as decimals.
Drop the beacons array and the quotes around the lat and long values and you should be ok.
Update
Your new pass is fine. It is not loading on the phone because your web server is not applying a Content-Type
header and therefore iOS does not recognise this file as a 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 a Content-Type: application/vnd.apple.pkpass
header to this file and you should find that it loads ok.
For more info on how to add the header, see the answers to this question.
sending PKPAss to Safari with PHP
Your web server is not correctly set up to serve the file with a MIME type that identifies the .pkpass file as a Passbook pass. More so, your server appears to be using a text or html MIME type that instructs the browser to read the file as text.
See my answer to this question for how to properly configure your server.
How many steps do I have to follow in order to update a pass for passbook
To push an update you need to follow the steps below:
- Build a RESTful web service to this specification
- Add an
webserviceURL
andauthenticationToken
to your pass.json - User installs the pass on their deivce
- Your web service, captures the
deviceLibraryIdentifier
andpushToken
- You create the updated .pkpass bundle
- Open a connection to the Apple Push Notification Service (APNS) using the Pass Type ID Certificate matching the
passTypeIdentifier
in your pass.json - Pack and send an APNS message containing the
pushToken
and an empty payload - Wait for the device to retrieve the push message and request the
serialNumber
of all updated passes matching thepassTypeIdentifier
(request may also contain apassesUpdatedSince
tag) - Your web service responds to the request from the device with the
serialNumber
of the updated pass (or passes updated since thepassesUpdatedSince
tag). - Wait for the device to respond with a request to send the new .pkpass bundle
- Your web service sends the updated .pkpass bundle to the device.
- The device processes the new pass and if appropriate, displays a notification.
You've already asked several times how to achieve steps 1 through 4 elsewhere on Stack Overflow.
I think you still are struggling to understand the concept that it is not YOU that registers the device - it is the DEVICE that registers itself.
Until you have built a web service that can catch and store the deviceLibraryIdentifier
and pushToken
, you won't be able to progress any further.
Related Topics
How to Tap on a Specific Point Using Xcode Uitests
Delivery Report of Sending Remote Push Notifications Using Apns - iOS
Swift - Error 'Expected ',' Separator' and 'Expected Expression in List of Expressions'
How to Programmatically Get iOS Status Bar Height
How to Scale a Uibutton's Imageview
Could Not Launch Process Launch Failed: Timed Out Waiting for App to Launch
Aligning Right to Left on Uicollectionview
Didupdatelocations Instead of Didupdatetolocation
Today App Extension Widget Tap to Open Containing App
How to Play Video Stream with Mpmovieplayercontroller in iOS
Fbsdkloginmanager Loginwithpublishpermissions Always Returns Iscancelled=Yes
Can't Cast Value of Type Uiviewcontroller to Patterndetailviewcontroller
"Too Many Symbol Files" After Successfully Submitting My Apps
Formatting Phone Number in Swift
Warning Frame for "Navigation Bar" Will Be Different at Run Time Appears in Xcode 8 Swift 3
iOS Nsattributedstring on Uibutton
Show Current Location and Update Location in Mkmapview in Swift