Pregunta

I am trying to share my app document (file url ) using UIActivityViewController. When activityviewcontroller pop up (testing on iPad device), I get only iMessage and Mail options. I DO NOT GET OTHER OPTIONS like Facebook, Twitter, Copy, Print, etc. Why? Please help me. I need Facebook, twitter options also. File type which I am sharing using NSURL is .txt

Note: I am already signed in to my Facebook, twitter account in iOS settings.

Source code which I am using:

NSURL *url = [NSURL fileURLWithPath:self.path];

NSArray *objectsToShare = @[url];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];


if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

    [APP_VIEW_CONTROLLER presentViewController:activityViewController animated:YES completion:nil];
}
else
{

    if (![self.activityPopover isPopoverVisible]) {
        self.activityPopover = [[UIPopoverController alloc] initWithContentViewController:activityViewController];
        [self.activityPopover presentPopoverFromRect:pathViewController.pathViewWrapper.pathView.bounds inView:pathViewController.pathViewWrapper.pathView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
    else
    {
        //Dismiss if the button is tapped while pop over is visible
        [self.activityPopover dismissPopoverAnimated:YES];
    }
}
¿Fue útil?

Solución

It is indeed mysterious what shows up in the UIActivityViewController. Regarding Facebook and Twitter 1) it likely needs to be an http or https URL (not a file URL), 2) make sure those services are configured on the simulator or iOS device you're using.

Otros consejos

For posting to Facebook. The file can be a file stored on the device locally. However, it needs to be converted to MP4. By default, videos taken by device camera are .MOV files. Once you convert to .MP4 if you provide the local file location, UIActivityController will share to Facebook.

I got FB to work, I'm working on Twitter now. I will edit my answer and provide details when I'm done.

Here is some code:

  UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:activities];

    activityController.excludedActivityTypes = @[ UIActivityTypeMail,
                                                  UIActivityTypeAssignToContact,
                                                  UIActivityTypePrint,
                                                  UIActivityTypeCopyToPasteboard,
                                                  UIActivityTypeAddToReadingList,
                                                  UIActivityTypeSaveToCameraRoll];

NSMutableArray *items = [[[Engine sharedEngine].thingsManager getSharingMessageForThingWithId:self.thingId
                                                                           categoryName:self.category.name
                                                                              brandName:self.brand.name
                                                                                andText:message
                                                                                isVideo:([self.videoURL.absoluteString length] > 0 ? YES : NO)] mutableCopy];
  if ([self.videoURL.absoluteString length] > 0) {
    //Get the .mp4 converted video url
    if (self.awsManager == nil) {
      self.awsManager = [[AWSManager alloc] init];
    }
    NSURL *mp4Url = [self.awsManager convertVideoToMP4:self.videoURL];
    //[items addObject:self.videoAmazonPath];
    [items addObject:mp4Url];
  } else {
    [items addObject:self.image];
  }

Hope this helps.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top