First thing first, you need to understand about inter-app communication.
What you need is custom url scheme for your app. Please Refer :
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Inter-AppCommunication/Inter-AppCommunication.html
Now after you have a custom url sheme, proceed as follows:
To get listed in the system wide share menu,You need to make a custom Activity.
Make a class like the following:
In the YourActivity.h file
@interface YourActivity : UIActivity
-(void)someInitialisationMethod:(NSString*)string;
@end
and in the YourActivity.m file
#import "YourActivity.h"
@implementation YourActivity
- (NSString *)activityType
{
return @"UIActivityCategoryShare";
}
- (NSString *)activityTitle
{ // here give the title of your app or the action name that it performs
return @"YourAppName";
}
+ (UIActivityCategory)activityCategory
{// there are two types of category- share and action
return UIActivityCategoryShare;
}
- (UIImage *)activityImage
{
// Note: These images need to have a transparent background and I recommend these sizes:
// iPadShare@2x should be 126 px, iPadShare should be 53 px, iPhoneShare@2x should be 100
// px, and iPhoneShare should be 50 px. I found these sizes to work for what I was making.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
return [UIImage imageNamed:@"YourActivityImage.png"];
}
else
{
return [UIImage imageNamed:@"YourActivityImage.png.png"];
}
}
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems
{
NSLog(@"%s", __FUNCTION__);
return YES;
}
- (void)prepareWithActivityItems:(NSArray *)activityItems
{
NSLog(@"%s",__FUNCTION__);
}
- (UIViewController *)activityViewController
{
NSLog(@"%s",__FUNCTION__);
return nil;
}
- (void)performActivity
{
// This is where you can do anything you want, and is the whole reason for creating a custom
// UIActivity
NSURL *yourCustomURLMaybe = [NSURL URLWithString:someInitialisedString];
if ([[UIApplication sharedApplication] canOpenURL: yourCustomURL]) {
[[UIApplication sharedApplication] openURL: yourCustomURL];
}
else
{
NSLog(@"YourActivity not found");
}
[self activityDidFinish:YES];
}
@end
Now that your custom activity is made
You need to fire it up with share menu like this
NSString *yourCustomUrl = [NSString stringWithFormat:@"YourCustomURLScheme?..."];
NSString *escapeAdded = [yourCustomUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *finalCustomURL = [NSURL URLWithString:escapeAdded];
YourActivity *ca;
if ([[UIApplication sharedApplication] canOpenURL: finalCustomURL])
{
ca = [[YourActivity alloc]init];
}
else
{
ca = nil;
}
NSArray *applicationActivityArray = [[NSArray alloc] initWithObjects:ca,nil];
Finally, When you present the share box, add the above array to application Activities:
activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[...] applicationActivities:applicationActivityArray];
}