How to share only text on Facebook Messenger for iOS?

How to share Text on viber , Facebook messenger and Instagram from iOS application?

  • If any one has idea about how to share text to viber Facebook messenger and instagram than please give some reference. i have try with defultcanOpenURL method for viber and Facebook-messenger as below: Code: NSURL *fbURL = [NSURL URLWithString:@"fb-messenger://user-thread/USER-ID/"]; if ([[UIApplication sharedApplication] canOpenURL: fbURL]) { [[UIApplication sharedApplication] openURL: fbURL]; } NSString * urlViber = [NSString stringWithFormat:@"viber://send? Text=text"]; NSURL * viberURL = [NSURL URLWithString:[urlViber stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; if ([[UIApplication sharedApplication] canOpenURL: viberURL]) { [[UIApplication sharedApplication] openURL: viberURL]; } else { Alert(@"Viber not installed.", @"Your device has no Viber installed.") } But the above code simply redirects to the application. It doesnt pass text to the application textfield. Waiting for helpful guideline from experts.. :)

  • Answer:

    Try the below code dude it will work out, If you got any problem inform me NSString *string = [NSString stringWithFormat:@"%@ \n\n%@ %@ \n\n%@", @"Hey !" ,Str_Moretext,Str_caption,@""]; NSURL *URL =[NSURL URLWithString:Str_ServerUrl]; //UIImage *image=[UIImage imageNamed:@"ReferUsers.png"]; @try { UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[string, URL] applicationActivities:nil]; [self presentViewController:activityViewController animated:YES completion:^{ }]; } @catch (id theException) { NSLog(@"Received error %@",theException); }

Pinank Lakhani at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

For Viber: [NSURL URLWithString:@"viber://forward?text=sdlmfkkanfj"] For Instagram: you have to share Image with text, Only text you cant share. NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"]; if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) { NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.igo"]; NSString *urlString = [[NSString alloc] initWithFormat:@"file://%@", jpgPath]; NSURL *imageUrl = [[NSURL alloc] initWithString: urlString]; self.docController = [self setupControllerWithURL:imageUrl usingDelegate:self]; self.docController.UTI = @"com.instagram.exclusivegram"; self.docController.annotation = [NSDictionary dictionaryWithObject:@"I_want_to_share_this_text" forKey:@"InstagramCaption"]; [self.docController presentOpenInMenuFromRect: self.view.frame inView: self.view animated: YES ]; }

hpDev_iOS

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.