Is there a way to get the URL scheme from the package id in iOS?

I am using a document based application. When other applications, such as dropbox, start my application to open the file, I get from this method the identifier of the package of the application that launched me (dropbox).

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ 

Now I would like to put a button that says “Return to Dropbox” and launch the Dropbox app. However, I will need to know the URL scheme in order to open it this way.

 [[UIApplication sharedApplication] openURL:myURL]; 

Is there a way to get the app url scheme from the package id?

I see that in Info.plist, when setting up the URL scheme for my application, the package identifier is also specified. Therefore, I believe that there should be a way to get one value from another.

thanks,

+1
source share
2 answers

Not. When configuring URL schemes, there is no agreement that states that they should be associated with the package identifier in general. If you are looking for a specific one or want to try to guess patterns of existing schemes, try here

+3
source

From iOS9, I think you do not need this feature, because iOS itself provides such a button in the upper left corner of your application. But if you want, you can use sourceApplication from the following delegate method.

 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ 

Here sourceApplication is the package ID of the application requesting your application to open the URL (url).

You can verify that the Dropbox package ID belongs and open the Dropbox app ultimately using one of the Dropbox URL schemes.

0
source

Source: https://habr.com/ru/post/1397948/


All Articles