Reputation: 1198
I am having two apps. I want to open a SecondApp from my FirstApp Button Click. Second App is having that custom Schema which is required for deep linking. Now I want to know what code I need to do on my FirstApp button click to open SecondApp?
Upvotes: 3
Views: 7906
Reputation: 362
In android, we can perform in the below ways
//Dial a phone
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:0377778888"));
startActivity(callIntent);
//View a map
// Map point based on address
Uri location = Uri.parse("geo:0,0?q=1600+Amphitheatre+Parkway,+Mountain+View,+California");
// Or map point based on latitude/longitude
// Uri location = Uri.parse("geo:37.422219,-122.08364?z=14"); // z param is zoom level
Intent mapIntent = new Intent(Intent.ACTION_VIEW, location);
startActivity(mapIntent);
//View a webpage
Uri webpage = Uri.parse("http://www.android.com");
Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage);
startActivity(webIntent);
Upvotes: -6
Reputation: 769
Try below code
let appURL: URL = URL(string: "CustomUrlScheme://")!
if UIApplication.shared.canOpenURL(appURL) {
UIApplication.shared.openURL(appURL)
}
Upvotes: 0
Reputation: 703
As much I can tell you in brief. You need to add custom Url schema for in your application.
For example you need to launch App2 from App1.
This is the code that you need to add in App2 info.plist or you can add "URL Types" in your info section of target.
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLName</key>
<string>com.company.App1</string>
<key>CFBundleURLSchemes</key>
<array>
<string>CompanyApp2</string>
</array>
</dict>
</array>
And this is the code that you need to add in you App1 info.plist file.
<key>LSApplicationQueriesSchemes</key>
<array>
<string>CompanyApp2</string>
</array>
Then you will launch App2 from App1 like as:
let app2Url: URL = URL(string: "CompanyApp2://")!
if UIApplication.shared.canOpenURL(app2Url) {
UIApplication.shared.openURL(app2Url)
}
Hope this will help.
Upvotes: 9