Sinu Varghese
Sinu Varghese

Reputation: 800

iOS Inter App communication using URL Schemes

I have 2 iPhone apps installed in the same device, app A and app B. app A doesn't have any remote server connectivity. app A has to invoke app B for the remote server communication. app B will make the server call & will return the response to app A. I want to use 'Apple URL Schemes' for this Inter App communication. The issue is that when app A invoke app B, app A will go to background and app B will come foreground. But I want this communication to happen without user notice. Always app A should be in the foreground for the user.

So the solution can be like this. app A invokes app b for the server call. app A will enter background mode and app B will come foreground. The method in the app A will detect the background mode & will bring it back to foreground. Similarly, method in app B will detect the foreground mode & will bring it back to background in some fraction of seconds. So the user will see only some flashing of screens when the apps switch. app B will execute the task in background & will return the result to app A.

I want to know whether this can be handled in iOS? Any suggestions are greatly appreciated.

Upvotes: 3

Views: 3971

Answers (3)

Dennis Ng
Dennis Ng

Reputation: 371

If one fix the scope in the question (like URL Scheme), you are limited by the scope. But if one free oneself, one may ask or keep on asking such as - is the App extension later help this question.

Upvotes: 0

sha
sha

Reputation: 17860

You can try something like that. I'm theorizing here, not sure if step #5-6 will actually work, but I think it worth trying

  • App A calls app B via URL scheme: openUrl: @"appB://startsomething"
  • App B become active and user will see that switch
  • App B starts network communication and immediately sends control back to the app A: openUrl: @"appA://resume
  • App A become active and user will see that switch again (so essentially app A will flick to app B and back
  • App B meanwhile is processing network request and when it completes it sends information to the App A using openUrl again: openUrl: @"appA://data=GOT_DATA"
  • App A is already active but it should receive this call and parse the data out

Upvotes: 6

Daij-Djan
Daij-Djan

Reputation: 50089

it can be handled PARTLY.

a can use b for the server call

but b has to stay in foreground to invoke the url back to a

Upvotes: 1

Related Questions