Reputation: 2351
I want to get specific information from the JSON in the pkpass file. The problem that I have is how to implement share functionality from wallet to my app and in general to register my app to work with PKPass.
For example, in the image, I want to have my app next to Mail and Message.
I try to add com.apple.pkpass as DocumentType like this:
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>PKPass</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.pkpass</string>
</array>
</dict>
After that, I understand that maybe I have to add it as imported UTI and I add this imported UTI:
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
<string>public.composite-content</string>
<string>com.apple.package</string>
</array>
<key>UTTypeDescription</key>
<string>PKPass</string>
<key>UTTypeIconFiles</key>
<array/>
<key>UTTypeIdentifier</key>
<string>com.apple.pkpass</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>pkpass</string>
</array>
</dict>
</dict>
And still, I can't share to my app. Maybe my question is: Is this possible? And if it is how to do it?
Any help will be highly appreciated.
Upvotes: 1
Views: 940
Reputation: 2351
Finally, I made it with App Extension, adding these lines in the plist file of the extension.
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
(
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.apple.pkpass-data"
)
).@count == 1
).@count == 1</string>
</dict>
<key>NSExtensionMainStoryboard</key>
<string>MainInterface</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.share-services</string>
</dict>
After that, I just unzip the pkpass file with a library and read the JSON file.
I hope this can be useful for someone else.
Upvotes: 2