我已經瀏覽了其他各種關於openURL沒有被調用的帖子,它們都不適用於我的情況,所以這裏是另一個。application:openURL:sourceApplication:annotation:當有MainWindow.xib時沒有調用
我想實現深度鏈接。我可以從鏈接打開應用程序,所以我的網址方案的作品。但是,openURL方法永遠不會被調用。
我在iOS 8
如果我刪除的MainWindow.xib我得到一個黑色屏幕(沒有整理出來編程它的細節),但OpenURL方法被調用時,它應該。
我的公司並不完全是項目的所有者,所以理想情況下會有一種方法可以使openURL與MainWindow.xib協同工作,或者顯示一些文檔說明這不被支持。
代碼: 在我applicationdelegate.m:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"open %@",url);
return YES;
}
在info.plist中:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.something.appish</string>
<key>CFBundleURLSchemes</key>
<array>
<string>schemename</string>
</array>
<key>CFBundleURLTypes</key>
<string>Viewer</string>
</dict>
</array>
我使用的鏈接schemename://什麼,com.something.appish: //任何東西
這些打開我的應用程序或將其帶到最前沿,但不會導致openURL調用。
關於這個問題以前的帖子包括:
- 的OpenURL應在應用程序的代理進行定義,而不是查看控制器。
- 嘗試handleOpenURL(適用於較早的iOS版本)。
- url scheme沒有正確定義。
- 應用程序未安裝的情況。
- 試圖打開特定的文件。
嗨。歡迎來到SO。你提供了一個問題,你描述得很好。現在所缺少的是你實現處理這些操作的代碼。 http://stackoverflow.com/help/how-to-ask – soulshined
謝謝。我已將代碼添加到帖子中。 – danadana
嗯,是的,你的代碼似乎都很好,並建立起來。你在真實設備上測試過嗎?嘗試用'schemename:// anything'打開它,然後登錄'NSLog(@「%@」,[url host]' – soulshined