Skip to content

Advanced Coupon List

Basic example

With these few lines of code

let vc = NITCouponListViewController()
vc.show()
NITCouponListViewController *vc = [[NITCouponListViewController alloc] init];
[vc show];

you are able to show the list of coupons.

Coupon List

Optionally, you can display the content in your UINavigationController:

let vc = NITCouponListViewController()
vc.show(navigationController: navigationController!, /*optional*/ title: "my coupons")
NITCouponListViewController *vc = [[NITCouponListViewController alloc] init];
[vc showWithNavigationController:self.navigationController];
// or
[vc showWithNavigationController:self.navigationController title:@"my coupons"];

Advanced Examples

Filter Coupons

You are able to filter the list of coupons with this options:

  • valid coupons
  • not yet active coupons
  • expired coupons

vc.filterOption = .disabled | .valid | .expired
vc.filterRedeemed = .show
vc.show()
vc.filterOption = NITCouponListViewControllerFilterOptionsValid | NITCouponListViewControllerFilterOptionsExpired | NITCouponListViewControllerFilterOptionsDisabled;
vc.filterRedeemed = NITCouponListViewControllerFilterRedeemedShow;
[vc show];

An automatic refresh every 5 seconds is attempted if a server or network problem occurs while the coupon list is being downloaded

Custom behaviour

Tapped coupons can be presented either as push in the UINavigationController or as a pop-over.

vc.presentCoupon = .popover
vc.presentCoupon = NITCouponListViewControllerPresentCouponPopover;

If you need more controll over the customization of the coupon controller you can configure a custom presentation callback. See this section.

vc.presentCoupon = .custom
vc.couponViewControllerConfiguration = { (couponVC: NITCouponViewController) -> Void in
    couponVC ...
    couponVC.show(fromViewController: nil, configureDialog: { (dialogController) in    
        dialogController.backgroundStyle = .blur
    })
}
vc.show()
vc.presentCoupon = NITCouponListViewControllerPresentCouponCustom;
vc.couponViewControllerConfiguration = ^(NITCouponViewController *couponVC) {
    [couponVC showFromViewController:nil configureDialog:^(NITDialogController *dialogController) {
        dialogController.backgroundStyle = CFAlertControllerBackgroundStyleBlur;
    }];
};

Manually handle coupons

You can get the coupon instance list directly from the SDK and decide what to do with them.

To get the coupon list, call:

manager?.coupons({ (coupons, error) in
    //Put your code here
})
[manager couponsWithCompletionHandler:^(NSArray *coupons, NSError *error) {
    //Put your code here
}];

UI Customization

Most aspects of the list UI can be customized, please refer to the main source code for the list of public variables.

vc.valueFont = UIFont.boldSystemFont(ofSize: 30)
vc.couponBackground = .normalBorders
vc.show()
controller.valueFont = [UIFont boldSystemFontOfSize:30.0];
controller.couponBackground = NITCouponListViewControllerCouponBackgroundNormalBorders;
[controller show];