I want to do a inter App communication in between two appliocation with URL Scheme. I have gone through Apple documentation,but won't get so much help.
I have make two projects, in sender there is one method in which i added
{
UIApplication *ourApplication = [UIApplication sharedApplication];
NSCharacterSet *set = [NSCharacterSet URLHostAllowedCharacterSet];
NSString *URLEncodedText = [@"TEST" stringByAddingPercentEncodingWithAllowedCharacters:set];
NSString *ourPath = [@"readtext://" stringByAppendingString:URLEncodedText];
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
else {
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Receiver Not Found"
message:@"The Receiver App is not installed"
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
NSLog(@"RECEIVER NOT FOUND");
}
}
And in Receiver app,added below code to App delegate
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
NSCharacterSet *set = [NSCharacterSet URLHostAllowedCharacterSet];
NSString *text = [[url host] stringByAddingPercentEncodingWithAllowedCharacters:set];
UIAlertController * alert= [UIAlertController
alertControllerWithTitle:@"Title"
message:text
preferredStyle:UIAlertControllerStyleAlert];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];
return YES;
}
Also what to add in info.plist and in URL types under Info.