Sharing text as a string to another app

You could use a custom URL scheme. Apps like Facebook and WhatsApp generally have their own schemes that you can use to send data into those apps. See WhatsApp's info here: Link

Alternatively, you could use a UIActivityViewController. This also supports other data types, not just strings (see this SO question).

    NSString *textToShare = @"your text";
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[textToShare] applicationActivities:nil];
    activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll]; //Exclude whichever aren't relevant
    [self presentViewController:activityVC animated:YES completion:nil];

Here's a nice blog post on this method: Link


In swift you can do like this to share a string

var shareString = "Hello i am share string please share me!";

        var activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [shareString], applicationActivities: nil);

        var currentViewController:UIViewController = UIApplication.sharedApplication().keyWindow!.rootViewController!

        currentViewController.presentViewController(activityViewController, animated: true, completion: nil);

the UIActivityViewController takes to parameters,

1st activityItems , which is an array of type Any, you can pass whatever you want to share, if you want to share different datatypes , you can use an NSArray and cast it to an array of any like that let activityItems : NSArray = [object1, object2] as! [Any]

2nd application activities, which is the services that your application may provided, which will be mostly nil.

For Swift 3 -> 4.2, Use the below syntax :

let yourMessage = "this is your\n message that you want to share !!"

let activityItems = [yourMessage]

let activityController = UIActivityViewController(activityItems: activityItems , applicationActivities: nil)

self.present(activityController, animated: true, completion: nil)