ios – Apple Pay不会显示预先填写的信息

在尝试在iOS应用程序中设置Apple Pay时,我们遇到了API和预填充信息的问题.我们的用户流程允许用户在使用Apple Pay付款之前手动设置其地址,电子邮件和电话,因此如果他们决定这样做,我们想确保填写Apple Pay提示符.

根据development guide,这应该是在request.shippingContact中设置这些值一样简单.但是,当我们这样做时,值将被忽略.

有什么文件没有告诉我们吗?

PKContact *contact = [[PKContact alloc] init];  
contact.emailAddress = @"john@appleseed.com";
contact.phoneNumber = [[CNPhoneNumber alloc] initWithStringValue:@"5555555"];

NSPersonNameComponents *name = [[NSPersonNameComponents alloc] init];
name.givenname = @"John";
name.familyName = @"Appleseed";
contact.name = name;

request.billingContact = contact;
request.shippingContact = contact;
request.requiredBillingAddressFields = PKAddressFieldAll;
request.requiredShippingAddressFields = PKAddressFieldEmail | PKAddressFieldPhone;

解决方法

如文档中所述,我们需要正确验证地址值.我们应该通过有效的邮政编码传递有效的地址,参见下面的代码.
PKContact *contact = [[PKContact alloc] init];

NSPersonNameComponents *name = [[NSPersonNameComponents alloc] init];
name.givenname = @"John";
name.familyName = @"Appleseed";

contact.name = name;

CNMutablePostalAddress *address = [[CNMutablePostalAddress alloc] init];
address.street = @"1234 Laurel Street";
address.city = @"Atlanta";
address.state = @"GA";
address.postalCode = @"30303";

还要检查:

注意

地址信息可能来自iOS中广泛的来源.在使用之前始终验证信息.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...