Skip to content

saru2020/SARAddressBookBackup

Repository files navigation

SARAddressBookBackup

An iOS library to take Backup of the device contacts as .vcf file.

Instructions :

(i) Copy/Include the "SARAddressBookBackup.h" & "SARAddressBookBackup.m" into your project.
(ii) Copy/Include  "MessageUI.framework" & "AddressBook.framework" into your project.
That's it. Your done.

Also, the Example project illustrates on how to email the .vcf file.

Installation :
Add the following to your CocoaPods Podfile

pod 'SARAddressBookBackup'

or clone as a git submodule,

or just copy SARAddressBookBackup.h and .m into your project.


Usage :

SARAddressBookBackup *addressBook = [[SARAddressBookBackup alloc]init];
addressBook.backupPath = [self applicationDocumentsDirectory];//(Optional). If not given, then the backup
// file is stored under the Documents directory.
__weak SARAddressBookBackup *addressBook_weak = addressBook;
__weak SARViewController *self_weak = self;
addressBook.backupCompletionStatusBlock = ^(NSString *status){
    if ( status == ACCESSDENIED) {
        NSLog(@"ACCESSDENIED : %@",ACCESSDENIED);
    }
    else if ( status == BACKUPFAILED) {
        NSLog(@"BACKUPFAILED : %@",BACKUPFAILED);
    }
    else if ( status == BACKUPSUCCESS) {
        NSLog(@"BACKUPSUCCESS : %@",BACKUPSUCCESS);
        NSLog(@"addressBook.backupPath : %@",addressBook_weak.backupPath);
        [NSTimer scheduledTimerWithTimeInterval:1.0 target:self_weak selector:@selector(emailBackup:) userInfo:addressBook_weak.backupPath repeats:NO];
    }
};
[addressBook backupContacts];


👨🏻‍💻 Author

  • Saravanan alt text

Buy me a coffee/beer

About

An iOS library to take backup of the device contacts as .vcf file

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published