user2138602 user2138602 - 1 month ago 12
iOS Question

App launched with custom URL scheme. How do I return data to the calling app when done?

I am taking an Android programming course at my University only I have been allowed by the teacher to do IOS but I have to implement the same projects. This project is to have two apps. The first app is a color picker from a previous assignment. The second app is to call the colorpicker and allow the user to choose a color and when done return it too the second app to be displayed.

I have defined a custom URL scheme in my ColorPicker which works fine. In my second app I have a changeColor button that has the following IBAction method.

- (IBAction)colorChangePressed:(UIButton *)sender {

UIApplication *test = [ UIApplication sharedApplication ];
BOOL found =
[ test openURL:[ NSURL URLWithString:@"colorPicker://" ] ];

if (found) NSLog( @"Resource was found" );

else NSLog(@"unable to locate resource" );
}


This indeed launches the color picker app and it behaves as expected. My question is, after the color has been selected how do I return to the calling app with the selected color? I will add a finished button in my colorPicker to be clicked when the user is done selecting the color and I will capture the values I need but I can't figure out how to get this data back to the calling app. Is there some protocol/delegate pattern I need to implement?

The complete code is on git hub at. https://github.com/jnels124/CS390H

Thanks in advance for any insight as to how to solve my problem.

Answer

I defined a custom scheme in the other project as stated in the first answer but I was unsure how to generate the query string in the called URL and return it to the calling application to be parsed. I had this resolved in the following post.

Syntax for passing NSArray to other application with custom URL Scheme

Comments