3

I am trying to launch one application(App 1) from another application (App 2)using URL schemes.Is there a way I can check application name which is launching my app? Example App2 launches App 1(So can I check for App 2 name while launching App 1) OR can we get information on the source which launched App1?

Thanks in advance

2 Answers 2

5

To have an application launched from another application, you just need to configure "supported url schemes" in your info plist file. You will be able to know the reason of your application launch as well from the following method in your appDelegate.

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Here launch options are

A dictionary indicating the reason the application was launched (if any). The contents of this dictionary may be empty in situations where the user launched the application directly.

The possible keys are

NSString *const UIApplicationLaunchOptionsURLKey; NSString *const UIApplicationLaunchOptionsSourceApplicationKey; NSString *const UIApplicationLaunchOptionsRemoteNotificationKey; NSString *const UIApplicationLaunchOptionsAnnotationKey; NSString *const UIApplicationLaunchOptionsLocalNotificationKey; NSString *const UIApplicationLaunchOptionsLocationKey; NSString *const UIApplicationLaunchOptionsNewsstandDownloadsKey;

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply.If App 1 was launched directly and then sent to background, then the same App 1 was launched by App2,then this delegate doesnt get called at all.Also it launches the same page on which it went to back ground not the first landing page. Any suggetions to resolve this problem.
@divya You can implement the following method in your app delegate -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation; This gets called when your application is in the background and there is a request to open this application.
0

Since the URL scheme is up to you, you can pass whatever info you want within the URL. For example:

[[UIApplication sharedApplication] openURL:@"app1scheme://app_action?source=app2"]; 

The only real advantage of this method over using the launch options keys is it also works—and could contain website specific info—if someone launches your app from a website link.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.