views:

15

answers:

0

Hi friends,

I am working on webview. I am loading a html page on my webview. the thing is when i clicked phone number in my page, it should automatically add into the contact of my json data. The issue it is working finely in simulator on device it is not working

Any suggestion is highly appreciated Thanks in advance

Regards, sathish

  • (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {

    ABRecordRef aRecord = ABPersonCreate(); CFErrorRef anError = NULL; ABRecordSetValue(aRecord, kABPersonFirstNameProperty, CFSTR("sathish"), &anError); ABRecordSetValue(aRecord, kABPersonLastNameProperty, CFSTR("kumar"), &anError); if (anError != NULL) {

    NSLog(@"error while creating.."); } CFStringRef firstName, lastName; firstName = ABRecordCopyValue(aRecord, kABPersonFirstNameProperty); lastName = ABRecordCopyValue(aRecord, kABPersonLastNameProperty);

    ABAddressBookRef addressBook; CFErrorRef error = NULL; addressBook = ABAddressBookCreate();

    BOOL isAdded = ABAddressBookAddRecord ( addressBook, aRecord, &error );

    if(isAdded){

    NSLog(@"added.."); } if (error != NULL) { NSLog(@"ABAddressBookAddRecord %@", error); } error = NULL;

    BOOL isSaved = ABAddressBookSave ( addressBook, &error );

    if(isSaved){

    NSLog(@"saved.."); }

    if (error != NULL) { NSLog(@"ABAddressBookSave %@", error); }

    CFRelease(aRecord); CFRelease(firstName); CFRelease(lastName); CFRelease(addressBook);

    return NO; } return YES; }