You do realise that in order to create a valid Apple Wallet Pass, you need to create a bundle, then sign it, compress and distribute?
This link to apple dev docs will help to get basic understanding of the process.
And according to this comment there are considerations to not to create passes directly in the app.
We met similar issue as yours - we have Ionic application for transportation tickets selling and we wanted to add the ability on iOS to add tickets to the Wallet.
All of the research I've done seems to show that currently (December 2019) it cannot be done.
Although, there is a workaround that you can use
It involves opening the link externally in system browser, so one may find this solution unsuitable.
- You need to have an endpoint (your API or a third-party service) that will return a generated and signed .pkpass file. It doesn't have to specifically return a file, but a response containing bundle with such headers:
Content-Type: application/vnd.apple.pkpass
Content-Disposition: attachment;filename=your_file_name.pkpass
- In your Ionic application install In App Browser native plugin
ionic cordova plugin add cordova-plugin-inappbrowser
npm install @ionic-native/in-app-browser
- Add it to your AppModule providers
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
@NgModule({
...
providers: [
...
InAppBrowser
],
})
export class AppModule {}
- In component inject
InAppBrowser
and call method create
with second parameter (target) as _system
. This command will open external native device browser with provided url. If endpoint configured correctly, browser will automatically start download and then present to user UI for adding Ticket/Pass to the Wallet. Here is a good example of the UI: Link to the image
constructor(private inAppBrowser: InAppBrowser) {
}
downloadApplePass(ticket) {
const url = `https://your.api/endpoint/${ticket.id}`;
this.inAppBrowser.create(url, '_system');
}