Reputation: 1119
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.. :)
Upvotes: 3
Views: 1984
Reputation: 180
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 ];
}
Upvotes: 0
Reputation: 3288
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);
}
Upvotes: 1