2016-09-07 79 views
1

我已經試過類似:如何從iOS 9中的電子郵件URL打開應用程序?

在AppDelegate中:

func application(application: UIApplication, handleOpenURL url: NSURL) -> Bool { 
    var returnValue = false 
    let urlString = url.absoluteString 
    print(urlString) 
    if(urlString.hasPrefix("")){ 
     returnValue = true 
    } 
    return returnValue 
} 

在info.plist中

<key>CFBundleURLTypes</key> 
<array> 
    <dict> 
     <key>CFBundleURLName</key> 
     <string>co.example.ExampleApp</string> 
     <key>CFBundleURLSchemes</key> 
     <array> 
      <string>example</string> 
     </array> 
    </dict> 
</array> 

但不起作用。我希望應用程序通過我通過電子郵件發送的鏈接打開,任何人都有想法使其工作?

+1

你跟着[這個例子](http://stackoverflow.com/documentation/ios/5173/deep-linking-in-ios/19598/adding-a-url-scheme-to-your-own-app #t = 201609071346266107572)來自文件? – FelixSFD

+0

你通過電子郵件發送了什麼鏈接?它應該看起來像'example:// some_path /' – iSashok

+0

是@iSashok,但仍然不起作用。 –

回答

0

對於將來的用戶,作爲@iSashok在評論中提到的handleOpenURL函數is deprecated as of iOS 9

對於iOS的更新版本,你需要使用下面的函數(Apple Docs):

optional func application(_ app: UIApplication, 
       open url: URL, 
       options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool 

您將能夠保持功能的身體和以前一樣,現在它會工作。

相關問題