-
Notifications
You must be signed in to change notification settings - Fork 1
/
PassKitHelper.swift
38 lines (34 loc) · 1.36 KB
/
PassKitHelper.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// PassKitHelper.swift
// DisableApplePay
//
// Created by Ashar, Snehanshu on 1/30/18.
// Copyright © 2018 Ashar, Snehanshu. All rights reserved.
//
import Foundation
import PassKit
@objc public class PassKitHelper:NSObject {
private static var tokenPKSuppresion:PKSuppressionRequestToken!;
public static func suppressApplePay() {
if #available(iOS 9, *) {
if( PKPassLibrary.isPassLibraryAvailable() && !PKPassLibrary.isSuppressingAutomaticPassPresentation()) {
tokenPKSuppresion = PKPassLibrary.requestAutomaticPassPresentationSuppression(responseHandler: { (result) in
if result == PKAutomaticPassPresentationSuppressionResult.success {
print("Automatic Pass Presentation suppressed")
}
else {
print("Could not suppress Automatic Pass Presentation")
}
})
}
}
}
public static func enableApplePay() {
if #available(iOS 9, *) {
if( PKPassLibrary.isPassLibraryAvailable() && PKPassLibrary.isSuppressingAutomaticPassPresentation()) {
PKPassLibrary.endAutomaticPassPresentationSuppression(withRequestToken: tokenPKSuppresion)
print("Automatic Pass Presentation enabled")
}
}
}
}