【问题标题】:Apple Pay - Can we extract email & phone number in Objective CApple Pay - 我们可以在 Objective C 中提取电子邮件和电话号码吗
【发布时间】:2016-07-05 18:46:19
【问题描述】:

未提取电子邮件 ID 和电话号码。我尝试使用的示例代码如下。谁能告诉我这里的问题?

ApplePayAddress *apAddress = [[ApplePayAddress alloc] init];
  apAddress.firstName = (__bridge NSString *)(ABRecordCopyValue(address, kABPersonFirstNameProperty));
  apAddress.lastName = (__bridge NSString *)(ABRecordCopyValue(address, kABPersonLastNameProperty));

  ABMultiValueRef addressMultiValue = ABRecordCopyValue(address, kABPersonAddressProperty);
  NSDictionary *addressDictionary = (__bridge_transfer NSDictionary *) ABMultiValueCopyValueAtIndex(addressMultiValue, 0);
  NSLog(@"AddressDictionary:%@",addressDictionary);

 apAddress.emailId = [addressDictionary objectForKey:(NSString *)kABPersonEmailProperty];
  apAddress.phNumber = [addressDictionary objectForKey:(NSString *)CNContactPhoneNumbersKey];
  apAddress.street = [addressDictionary objectForKey:(__bridge NSString *)kABPersonAddressStreetKey];
  apAddress.city = [addressDictionary objectForKey:(__bridge NSString *)kABPersonAddressCityKey];
  apAddress.state = [addressDictionary objectForKey:(__bridge NSString *)kABPersonAddressStateKey];
  apAddress.zip = [addressDictionary objectForKey:(__bridge NSString *)kABPersonAddressZIPKey];
  apAddress.country = [addressDictionary objectForKey:(__bridge NSString *)kABPersonAddressCountryKey];
  apAddress.countryCode = [addressDictionary objectForKey:(__bridge NSString *)kABPersonAddressCountryCodeKey];

【问题讨论】:

    标签: ios contacts applepay


    【解决方案1】:

    您可以使用以下代码提取电话号码和电子邮件:将此代码写入 didAuthorizePayment 委托方法

    ABMultiValueRef addressMultiValue1 = ABRecordCopyValue(payment.shippingAddress, kABPersonEmailProperty);
    apAddress.emailId = (__bridge NSString *)ABMultiValueCopyValueAtIndex (addressMultiValue1, 0);
    
    ABMultiValueRef addressMultiValue2 = ABRecordCopyValue(payment.shippingAddress, kABPersonPhoneProperty);
    apAddress.phoneNumber = (__bridge NSString *)ABMultiValueCopyValueAtIndex (addressMultiValue2, 0);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-22
      • 2018-05-05
      • 1970-01-01
      相关资源
      最近更新 更多