Is there way to get list of installed app on device, which is able to share and receive text data

559 views Asked by At

Like for sharing text data with Whatsapp code is below. i want to know all installed apps on device which is able to get text data, like below mention code.

 NSString * msg = @"YOUR MSG"; NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg]; NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
        [[UIApplication sharedApplication] openURL: whatsappURL]; } else {
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show]; }
2

There are 2 answers

0
Vinod N On BEST ANSWER

Sharing text,data with other social app than twitter/facebook. You can try the code below :

NSString *shareString = @"text...";
UIImage *shareImage = [UIImage imageNamed:@"image.png"];
NSURL *shareUrl = [NSURL URLWithString:@"http://www.test.com"];

NSArray *activityItems = [NSArray arrayWithObjects:shareString, shareImage, shareUrl, nil];

UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;

[self presentViewController:activityViewController animated:YES completion:nil];

It will display activity view showing all other text sharing app.

Or You can also create your custom UIActivity also. In your custom UIActivity subclass you have to simply override one method:

+ (UIActivityCategory)activityCategory
{
   return UIActivityCategoryShare;
}
0
Kamal Bhardwaj On

There is UIActivityViewController to list all apps, where you can share your text. And you can customize the list via "More" option there. Also apps having share extension will automatically lists there. enter image description here