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
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:
- How to send invitation to my facebook friends from iOS app?Best solution by Stack Overflow
- How to share individual images on Facebook?Best solution by Ask Ubuntu
- How to share native image and text on Facebook and Twitter?Best solution by Stack Overflow
- How do you change text color on facebook?Best solution by Quora
- Facebook Messenger Connection Problem?Best solution by facebook.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.