I want to open an app and return from it with some return values like success or fail. How to do it?
From the documentation
[scheme]://[host]/[action]?[x-callback parameters]&[action parameters]
Question 1:
What should I place in [action parameters]? Is it compulsory?
Sending App A
- (IBAction)openReceivingAppBButtonPressed:(id)sender {
NSString *xcallBack = @"x-callback-url/payment?&amount=1.00";
NSString *URLEncodedText = [xcallBack stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *ourURL = [NSURL URLWithString:[@"receivingAppB://" stringByAppendingString:URLEncodedText]];
if([[UIApplication sharedApplication] canOpenURL:ourURL]){
[[UIApplication sharedApplication] openURL:ourURL];
}
}
Receiving App B
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
[self returnToSendingAppAWithResponse];
return true;
}
-(void)returnToSendingAppAWithResponse{
NSString *xcallBackSuccess = @"success";
NSString *URLEncodedText = [xcallBackSuccess stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *ourURL = [NSURL URLWithString:[@"sendingAppA://" stringByAppendingString:URLEncodedText]];
if([[UIApplication sharedApplication] canOpenURL:ourURL]){
[[UIApplication sharedApplication] openURL:ourURL];
}
}
Question 2:
In the receiving app, is it correct to call another openURL call to the Sending App A to return the success message?
I'm able to achieve what I want. But just doubt whether this is the correct way of using x-callback-url. x-callback-url doesn't seem to be useful to me.