2016-03-18 40 views
2

電子郵件ID和電話號碼未被提取。下面是我嘗試使用的示例代碼。任何人都可以讓我知道這裏的問題嗎?Apple Pay - 我們可以提取目標C中的電子郵件和電話號碼嗎?

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]; 

回答

0

您可以使用下面的代碼中提取電話號碼和電子郵件:寫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); 
相關問題