URL Schemes-sending action ios - ios

I have devoleped 3 applications,one of them called Main-app and it contains icons of the two others app and a button to access to thew from the main-app.the problem is that if I want to add an app from the app store,how can I get the icon and create a button dynamically into the main-app? I suggest to use URL Schemes between apps but I dont know how to do it.

One way is to have all the app names and icons in each app's bundle and differentiate them using the "sourceApplication" parameter of the application:openURL:sourceApplication:annotation: method of UIApplicationDelegate

Related

Invoke the back-to-app button programmatically

Is is possible to call the "back-to-app" button programmatically? I have only seen questions for the scenraio when people want to call back-to-app from OtherApp which I understand why it shouldn't be available.
MyApp -> OtherApp : call back-to-app from OtherApp.
However in my scenario is this:
OtherApp -> MyApp : call back-to-app from MyApp.
Is it possible to send the user from MyApp back to where they were before? Because my app has completed its purpose?
If you’re talking about the button that appears at the top left when switching apps, no you can not invoke that button.
For your app to open another app you’ll need to know the URL Scheme of the app you want to open. The other app must also be setup to handle this URL Scheme.
If you own both apps you can implement the URL Scheme yourself. If not, you’ll need to reach out to the developer of the other app to see if they have a URL Scheme you can open their app with.
Apple docs: Defining a Custom URL Scheme for Your App

Open application on button tapped with Bundle Identifier (Without url scheme)

I'm currently developing an app and i'm trying to add a button which would open another app installed on my phone when the button is tapped
I've tried looking for the URL scheme for the app but i can't find it. Only thing i can find is the bundle ID. So i thought maybe there's a way to use the bundle ID to open the app through private APIs in Swift? My phone is jailbroken if that helps. Below is my code
#IBAction func openAppTapped(_ sender: Any) {
UIApplication.shared.openURL(NSURL(string: "itms-apps://itunes.apple.com/us/app/apspace/id1413678891?mt=8")! as URL)
}
I managed to upon the app on the appstore upon tapping the button but i want a way to open the app directly without using url schemes but instead using the bundle id and/or private APIs. Any help would be really really appreciated!
To open another app, you are either going to have to use some kind of extension provided by that app or figure out their URL scheme and reverse engineer it.
The first thing you could try is looking at the app's Info.plist and seeing if they have defined a URLScheme for their app. If not, and they haven't implemented an extension, then I think you're SOL.
If they did define it, try using it to open their app and see what happens, they might have some code that rejects or accepts a request to open their app based on the format of the URL after their scheme. If you can't figure it out with trial and error, you could use the fact that your phone is jailbroken to decompile their app and hunt down the URL parsing logic which is likely in their AppDelegate. From there you could try and build a URL that you can use to successfully open their app every time.

iOS App Extensions (Widgets): Open URL, and then execute a method within the app

In an iOS App Extension such as the Today Widget, you can open the application when the widget is selected using NSExtensionContext. Is there any way to execute a method within the application (to move to a different UI view) only after the application is opened via the widget?
You will have to create a custom URL scheme which your app will register for and change the view based on the URL.
Example: myapp://action=showspecialview
Your app would then be launched and can parse the URL and do the special behavior when it detects showspecialview in the URL.

Open iOS app from browser

What I want to do is,
We have having one product info on Website.
That product is available on store.
what we have on website is that, Product info and one button for that product.
I want to take two actions on that button.
When User opens website on iPad or iPhone on Safari (browser) and click on GetProduct button, then following two actions must be taken place.
1. If user is already having product installed on device then directly open the app in device.
2. If user is not having the app on device then link user to the app on store, so he can download from there.
I already handled second condition,
but how to handle the first condition.
If I am already having the app then how to open it on action of button click in browser.
You can achieve what you're asking for by using a URL scheme. This will enable you to call the openUrl: method with your application's url scheme which will then launch your app.
Here's how you setup a custom url scheme:
Open your app's Info.plist and add a row with a key called URL Types.
Expand the URL Types item, and Item 0 under it and you'll see URL Identifier
Enter your app's bundle identifier (e.g. com.myCompany.myApp) as the URL Identifier value.
Add another row to Item 0 and enter URL Schemes.
Expand the URL Schemes and under Item 0 type in the name for your custom scheme (e.g. myScheme).
You should now be able to open your app from Safari by typing myScheme:// in the address bar.
Alternatively, from your app, you can launch the other app like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"myScheme://"]];
Note that you can also send parameters to the app you're launching with the url scheme (more on that here).
With iOS9 Apple introduced a way to open installed app from Links. Here is the official link for this : Apple universal links

Post link to Facebook including app URL scheme - iOS 6

I'm using the UIActivityViewController to share an image and url from within my app.
I'm having trouble formatting the facebook post. I attach an image using a subclassed UIActivityItemProvider and provide the text for the post in the same way.
I want to add a url, but it needs my apps custom url scheme in front of it like this
myurl://image?url=http://imageurl.com
The problem is, when this is posted, only the last half of the url is clickable (from http:// onwards). Which means it doesn't open my app with the url.
Is there another way to do this?
I know I can create an app on Facebook, but how can I tie the two together using the UIActivityViewController?
Thanks
You have 2 options :
Create a simple server-side web service that will redirect from http://yourserver.com/linkToApp/image to myurl://image .
It could even show a different page/preview if the app is not installed/if you're not on an ios device.
Create a facebook app and use "Deep linking" (it will basically do the same for you..)

Resources