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.

In your AppDelegate.m or AppDelegate.swift, implement the following delegate to handle passes natively:

...In the top of your delegate file
#import <PassKit/PassKit.h>

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

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

    //Init a pass object with the data
    PKPass * pkPass = [[PKPass alloc] initWithData:data error:&error];

    if(!error){
        //Present PKAddPassesViewController controller in your own navigation controller
        PKAddPassesViewController * vc = [[PKAddPassesViewController alloc] initWithPass:pkPass];
        [vc setDelegate:self];

        UINavigationController *navController = (UINavigationController *)self.window.rootViewController;

        [[NotificarePushLib shared] presentWalletPass:notification inNavigationController:navController withController:vc];
    }
}
...In the top of your delegate file
import PassKit

...more code
func notificarePushLib(_ library: NotificarePushLib, didReceivePass pass: URL, in notification: NotificareNotification) {
    let data = Data(contentsOf: pass)
    var error: Error?
        //Init a pass object with the data
    let pkPass = try? PKPass(data: data)
    if error == nil {
            //Present PKAddPassesViewController controller in your own navigation controller
        let vc = PKAddPassesViewController(pass: pkPass)
        vc.delegate = self
        let navController = window.rootViewController as? UINavigationController
        NotificarePushLib.shared().presentWalletPass(notification, in: navController, with: vc)
    }
}

The methods above will let you display a pass when received via a remote notification, but there can be situations where you would like to retrieve passes in your application. If that is the case you can still do so using the methods below.

If you would like to have the a specific Notificare's pass object using the serial (auto-generated), simply invoke the following method:

[[NotificarePushLib shared] fetchPassWithSerial:@"SERIAL_NUMBER" completionHandler:^(id  _Nullable response, NSError * _Nullable error) {
    if (!error) {
        //Response will be a NotificarePass object
    }
}];
NotificarePushLib.shared().fetchPassWithSerial("SERIAL_NUMBER", completionHandler: {(_ response: Any?, _ error: Error?) -> Void in
    if error == nil {
        //Response will be a NotificarePass object
    }
})

If instead, you've created passes with a custom barcode, use the following method:

[[NotificarePushLib shared] fetchPassWithBarcode:@"BARCODE" completionHandler:^(id  _Nullable response, NSError * _Nullable error) {
    if (!error) {
        //Response will be a NotificarePass object
    }
}];
NotificarePushLib.shared().fetchPassWithBarcode("BARCODE", completionHandler: {(_ response: Any?, _ error: Error?) -> Void in
    if error == nil {
        //Response will be a NotificarePass object
    }
})