2017-06-21 6 views
1

Ich habe zwei Apps. Ich möchte eine SecondApp von meinem FirstApp Button Click aus öffnen. Zweite App verfügt über das benutzerdefinierte Schema, das für die Deep-Linking erforderlich ist. Jetzt möchte ich wissen, welchen Code ich auf meiner FirstApp-Schaltfläche klicken muss, um SecondApp zu öffnen?Öffnen Sie eine andere App von Meine App?

+0

prüfen dieses Tutorial: http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html –

+0

lese tiefe Verknüpfung zuerst –

Antwort

4

So viel kann ich Ihnen kurz sagen. Sie müssen in Ihrer Anwendung ein benutzerdefiniertes URL-Schema hinzufügen.

Zum Beispiel müssen Sie App2 von App1 starten.

Dies ist der Code, den Sie in App2 info.plist hinzufügen müssen, oder Sie können "URL-Typen" in Ihrem Infobereich des Ziels hinzufügen.

<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> 

Und das ist der Code, den Sie in Ihrer App1 info.plist-Datei hinzufügen müssen.

<key>LSApplicationQueriesSchemes</key> 
<array> 
    <string>CompanyApp2</string> 
</array> 

Dann werden Sie App2 von App1 starten wie zum Beispiel:

 let app2Url: URL = URL(string: "CompanyApp2://")! 

     if UIApplication.shared.canOpenURL(app2Url) { 
      UIApplication.shared.openURL(app2Url) 
     } 

Hope this helfen.

+0

@Niharika. Wenn Sie das Gefühl haben, dass es Ihnen hilft. Dann markieren Sie es als akzeptable Antwort. –

+0

Funktioniert perfekt. Weißt du, wie direkt zu einem bestimmten View-Controller innerhalb der App mit einem Benutzernamen/ID? z.B. "instagram: // user? username = johndoe" öffnet instagram die Profilseite mit dem Benutzernamen von johndoe – luke

0

Try Code unten

let appURL: URL = URL(string: "CustomUrlScheme://")! 
    if UIApplication.shared.canOpenURL(appURL) { 
     UIApplication.shared.openURL(appURL) 
    } 
-2
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); 
Verwandte Themen