我想創建一個示例項目,當用戶單擊我的應用上的「Pay with Apple Pay」按鈕時,打開Apple Pay表單。無法在iPhone 6上打開Apple Pay表單
我使用iOs版本8.1(包含Apple Pay)和Xcode 6.1 GM在iPhone 6上測試我的應用程序。他們兩人還沒有正式發佈。我接着教程this page。這是我處理的按鈕「與蘋果支付支付」上的點擊事件代碼:
PKPaymentRequest *request = [PKPaymentRequest new];
// Must be configured in Apple Developer Member Center
// Doesn't seem like the functionality is there yet
request.merchantIdentifier = @"my.valid.merchant.identifier";
request.countryCode = @"US";
request.currencyCode = @"USD";
// Let's go!
// if (![PKPaymentAuthorizationViewController canMakePayments]) return;
PKPaymentAuthorizationViewController *authVC = [[PKPaymentAuthorizationViewController alloc] initWithPaymentRequest:request];
authVC.delegate = self;
[self presentViewController:authVC animated:YES completion:nil];
點擊按鈕「與蘋果的工資報酬」,我得到這個錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nil modal view controller on target
檢查PKPaymentAuthorizationViewController canMakePayments]
時,它返回false。
我不知道我錯誤的原因是iPhone的設置或我的代碼。
有人有Apple Pay的經驗嗎?請幫幫我。非常感謝。
難道你不覺得你在評論canMakePayments嗎?如果它返回「否」,那麼爲什麼你會期望它工作? – borrrden 2014-10-09 02:48:02
@borrrden我評論它是爲了檢查Apple Pay表單是否顯示錯誤消息,否則它將返回代碼錯誤。由於缺乏文件。我試圖儘可能調查所有情況: – haotang 2014-10-09 02:55:46
是的,遇到同樣的問題...... – iAnurag 2014-11-18 10:15:32