3

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.. :)

Ashok Londhe
  • 1,491
  • 11
  • 29
Pinank Lakhani
  • 1,109
  • 2
  • 11
  • 31
  • Have you searched properly? use social framework or facebook SDK to share text – Sujay Jun 04 '15 at 06:06
  • I am done with facebook sharing and have no issue with it. But i'm facing difficulty in fb-messanger sharing. i have tried with FBSDKMessengerShareKit.framework and guidelines from developers portal but there are no references for text only. All available methods are for media sharing. you can check it from following link https://developers.facebook.com/docs/messenger/ios as well as from framework also. – Pinank Lakhani Jun 04 '15 at 06:41

2 Answers2

1

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);

    }
Nischal Hada
  • 3,230
  • 3
  • 27
  • 57
  • i dont want to do it with UIActivityViewController. its simple and i already know about it i want separate sharing for all apps and i'm already done with all the social apps except fb-messanger and viber. – Pinank Lakhani Jun 04 '15 at 07:38
0

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
  • 170
  • 9