SDK

Implementation

By default, when you use push notifications to send your passes, our library will only handle web passes. However you can always use PassKit native controllers to present your native Wallet passes.

For this you need to change our Cordova plugin and uncomment all the references to PassKit we've included. Start by adding the following in the NotificarePushLibCordova.m file:

#import <PassKit/PassKit.h>
...more code

@interface NotificarePushLibCordova : CDVPlugin <NotificarePushLibDelegate> {

..more code

}

Then uncomment the following method:

- (void)notificarePushLib:(NotificarePushLib *)library didReceivePass:(NSURL *)pass inNotification:(NotificareNotification*)notification{

    NSData *data = [[NSData alloc] initWithContentsOfURL:pass];
    NSError *error;

    PKPass * pkPass = [[PKPass alloc] initWithData:data error:&error];

    if(!error){
        PKAddPassesViewController * vc = [[PKAddPassesViewController alloc] initWithPass:pkPass];
        [vc setDelegate:self];
        [[NotificarePushLib shared] presentWalletPass:notification inNavigationController:[[NotificareReactNativeIOS getInstance] navigationControllerForRootViewController] withController:vc];

    }

}

After these changes, all passes you send in a push message will be handled as a native Wallet pass.

You can also request passes by their serial and retrieve the raw pass object:

Notificare.fetchPassWithSerial(serial).then((result) => {
  //Handle success
}).catch((e) => {
  //Handle error
});

If instead you wish to retrieve a pass using its custom barcode, you should use the following method:

Notificare.fetchPassWithBarcode(barcode).then((result) => {
  //Handle success
}).catch((e) => {
  //Handle error
});