I am new to UIActivityViewController and perhaps I am missing a basic understanding. What I am trying to do is attached a csv, xml and vcard file to activity controller and show dropbox, google drive etc options. I have downloaded and installed dropbox, google drive etc apps on my iPhone.
Now when I launch UIActivityViewController all I see are default message and email app in my acitivity controller. How can I have other apps show up on their too? Do I need to install each and every apps individual SDKs and somehow incorporate them in my app?
This is what I wold like to see

but this is what I see instead.

Here's the code that I have tried so far
-(IBAction) dropBoxAction
{
    paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES);
    NSString* documentsPath = [paths objectAtIndex:0];
    //CSV
    NSMutableString *fileNameStr = [NSMutableString stringWithFormat:@"test_CSV_Backup.csv"];
    NSString* csvDataFileStr = [documentsPath stringByAppendingPathComponent:fileNameStr];
    NSData *csvData = [NSData dataWithContentsOfFile:csvDataFileStr];
    //EXCEL
    NSMutableString *fileNameStr2 = [NSMutableString stringWithFormat:@"test_EXCEL_Backup.xml"];
    NSString* excelDataFileStr = [documentsPath stringByAppendingPathComponent:fileNameStr2];
    NSData *excelData = [NSData dataWithContentsOfFile:excelDataFileStr];
    //VCARD
    NSMutableString *fileNameStr3 = [NSMutableString stringWithFormat:@"test_VCARD_Backup.vcf"];
    NSString* vcardDataFileStr = [documentsPath stringByAppendingPathComponent:fileNameStr3];
    NSData *vcardData = [NSData dataWithContentsOfFile:vcardDataFileStr];
    //adding them all together
    NSMutableArray *sharingItems = [NSMutableArray new];
    [sharingItems addObject:csvData];
    [sharingItems addObject:excelData];
    [sharingItems addObject:vcardData];
    UIActivity *activity = [[UIActivity alloc] init];
    NSArray *applicationActivities = @[activity];
    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:applicationActivities];
    [self presentViewController:activityController animated:YES completion:nil];
}
                As @rmaddy said, you should use UIDocumentInteractionController to replace UIActivityViewController, just like this:
UIDocumentInteractionController *dc = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:fileNameStr]];
[dc presentOptionsMenuFromRect:self.view.bounds inView:self.view animated:YES];
                        For anyone interested in future, here's the code all in one place. Do rate it up if this helps.
In your *.h file add this
@interface v1BackupComplete : UIViewController <UIDocumentInteractionControllerDelegate>
{
    UIDocumentInteractionController *docController;
}
In your *.m file add this
/************************
 * Dropbox ACTION
 ************************/
-(IBAction) dropBoxAction2
{
    NSLog(@"dropBoxAction2 ...");
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask ,YES);
    NSString* documentsPath = [paths objectAtIndex:0];
    NSMutableString *fileNameStr3 = [NSMutableString stringWithFormat:@"test_VCARD_Backup.vcf"];
    NSString* vcardDataFileStr = [documentsPath stringByAppendingPathComponent:fileNameStr3];
    NSURL *fileURL = [NSURL fileURLWithPath:vcardDataFileStr];
    docController = [self setupControllerWithURL:fileURL
                                   usingDelegate:self];
    bool didShow = [docController presentOpenInMenuFromRect:self.view.bounds inView:self.view animated:YES];
    NSLog(@"didShow %d ...", didShow);
    if (!didShow)
    {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ERROR"
                                                        message:@"Sorry. The appropriate apps are not found on this device."
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles: nil];
        [alert show];
    }
}
#pragma mark - UIDocumentInteractionControllerDelegate
- (UIDocumentInteractionController *) setupControllerWithURL:(NSURL *)fileURL
                                               usingDelegate:(id <UIDocumentInteractionControllerDelegate>)         interactionDelegate {
    UIDocumentInteractionController *interactionController =
    [UIDocumentInteractionController interactionControllerWithURL:fileURL];
    interactionController.delegate = interactionDelegate;
    return interactionController;
}
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    return self;
}
- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
    return self.view;
}
- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
    return self.view.frame;
}
                        UIActivityViewController only shows standard built-in activities plus any custom activities you pass as applicationActivities.
For what you are doing, you don't want UIActivityViewController. You want a UIDocumentInteractionController. If you just want to display existing apps that can open the file, use one of the presentOpenInMenuFrom... methods.
But note that is to be used for just a single file, not three.
Passing three files makes no sense in this context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With