1

I add an activityViewController to my app like below, passing in an image

UIActivityViewController *avc = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:img,nil] applicationActivities:[NSArray arrayWithObjects:nil]];
        [self presentModalViewController:avc animated:YES];
        [avc release];

On the simulator (twitter, facebook and weibo accounts all not configured):

options mail, twitter, facebook, weibo, assign to contact, save to camera roll, print, and copy appear by default.

but on device:

in my app: twitter, facebook and weibo only show if the accounts are configured.

in safari: twitter, facebook and weibo options are available irregardless of whether the accounts are configured.

I am expecting the same behaviour in my app as safari. am I missing a particular step?

tzl
  • 1,540
  • 2
  • 20
  • 31

2 Answers2

2

Okay I have figured the problem.

The options shown in the UIActivityViewController totally depends on the type of items that are to be shared. For example, if there is a video, it will not show Facebook or twitter option. But if it's an image and title, it definitely will show the relevant options.

The following will show up apps like mail, twitter, Facebook, assignToContact, save to camera roll, print, copy, etc

// Create the content
NSString *message = @"The Upcoming App Scribble Talk";
UIImage *imageToShare = [UIImage imageNamed:@"createbtn.png"];

NSArray *objectsToShare = [NSArray arrayWithObjects:message, image, nil];

However, the following shall bring up only camera roll, mail or copy.

NSString *message = @"The Upcoming App Scribble Talk";
NSString *videoToShare = @"myFirsScribble.mov";
NSURL *videoPath = [NSURL fileURLWithPath:videoToShare];

NSArray *objectsToShare = [NSArray arrayWithObjects:message, videoPath, nil];
LeoSarena
  • 189
  • 2
  • 8
0

I think you want to show some certain service only in your UIActivityViewController. You may one property called excludedActivityTypes to be defined as below to avoid some default activity.

UIActivityViewController *yourvc = [[UIActivityViewController alloc]initWithActivityItems:[NSArray arrayWithObjects:img,nil] applicationActivities:[NSArray arrayWithObjects:nil]];
yourvc.excludedActivityTypes = @[UIActivityTypePostToWeibo,UIActivityTypePrint,UIActivityTypeMail,UIActivityTypeCopyToPasteboard];//Try this code in simulator.. you can only see FB & Twitter.  
        [self presentModalViewController:yourvc animated:YES];
        [avc release];

likewise you can excluded from default UIActivityViewController..

Mani
  • 17,549
  • 13
  • 79
  • 100
  • sorry i think i should be clearer. I would like twitter, facebook and weibo options to a available in the app, on device, even if the user does not have accounts linked to the device in settings – tzl Apr 04 '13 at 10:02
  • Above code will made available those options evenif account didn't configured with device.. – Mani Apr 04 '13 at 10:18
  • this works on the simulator(but the behaviour on simulator was correct to begin with), but not on the device. for you, on the device, without configuring a facebook account, was the facebook option available in the activitycontroller? – tzl Apr 04 '13 at 10:37
  • Sure, without configuring any account , facebook or twitter or weibo will available in the activityviewController. You can exclude all other than these three. And launch your app on device. You can see these three option only on your app. I'm sure. It should work.. – Mani Apr 04 '13 at 10:43
  • 1
    unfortunately I have been unable to observe this on my phone or my colleagues :( – tzl Apr 13 '13 at 08:37
  • I am having the same issue :( I can't find options for Facebook or twitter in UIActivity on the device. – LeoSarena Nov 26 '13 at 06:51