2016-05-18 79 views
1

我想要的是在iOS中從我的Xamarin Forms應用程序中打開另一個應用程序。我在iOS中閱讀了關於URL方案的內容,但是如何在Xamarin應用程序中實現它。我正在使用依賴項服務來調用本地函數。我在Android中完成了這項工作,並且完美地工作。如何使用URL方案從我的應用程序在Xamarin iOS中打開另一個應用程序

我找到了一個鏈接 https://riccardo-moschetti.org/2014/10/03/opening-a-mobile-app-from-a-link-the-xamarin-way-url-schemas/。但它使用Xamarin Studio,我使用的是Visual Studio,VS2015沒有這個選項。

任何人都有更好的解決方案嗎?

+0

u能得到info.plist中的XML版本的IDE都。複製和粘貼, ,應該解決你的問題 –

+0

但我將不得不將解決方案複製到MAC,因爲Xamarin不支持Windows上的iOS開發。 –

+0

它確實支持,你只需要有一個用於構建的Mac! –

回答

1

我已經通過在我想打開的應用程序的info.plist中添加下面的鍵來解決它。

<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
     <key>CFBundleURLName</key> 
     <string>com.example.ios</string> 
     <key>CFBundleURLSchemes</key> 
     <array> 
      <string>testscheme</string> 
     </array> 
    </dict> 
</array> 

,然後使用下面的代碼來打開應用程序

if(!UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("testscheme://com.example.ios"))) 
{ 
//Use the code below to go to itunes if application not found. 
UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("itms://itunes.apple.com/in/app/appname/appid")); 
} 
相關問題