ios - IOS Swift 4 AppDelegate 应用程序处理接收自定义 URL AirDrop 文件未命中
问题描述
我的 iPhone 应用程序通过 AirDrop 将自定义 URL 文件发送到我的 iPad 应用程序。该 URL 的扩展名为 .fdre。发送后,iPad 应用程序将打开。但是,在 AppDelegate 中处理接收自定义文件的应用程序函数似乎从未受到影响。任何帮助将不胜感激。
我的“发送”应用程序中有这个:
func exportToURL (data : String) -> URL {
var input : String = ""
let url = self.getDocumentsDirectory().appendingPathComponent("FUNduroResult.fdre")
do {
try data.write(to: url, atomically: true, encoding: .utf8)
input = try String(contentsOf: url)
print(input)
print(url)
} catch {
print(error.localizedDescription)
}
return url
}
@IBAction func airdropButton(_ sender: Any) {
let text = formatDataAsCSV()
let url = exportToURL(data: text)
let activity = UIActivityViewController(
activityItems: ["Check out this result for the FUNduro.", url],
applicationActivities: nil
)
activity.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem
present(activity, animated: true, completion: nil)
}
我在接收应用程序的 AppDelegate 中有这个:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if url.pathExtension == "fdre" {
print("got result")
}
return true
}
我在我的接收应用程序中有这个文件类型:
干杯 kbjb
解决方案
推荐阅读
- google-apps-script - 通过谷歌脚本检索最左边工作表的名称
- r - 如何为数据框的每一行创建列联表
- c - 从浮点数创建有理数会产生不精确的结果
- makefile - 错误(制作:***没有规则使目标“检查”。停止。)
- python - 来自 3D 阵列的 1D 图
- java - 我可以在 Java 中创建一个条件变量数组吗?
- c++ - 在 C++ 中通过引用传递结构不会更新值
- python - python搜索并查找数组2d中的指定数字位置
- typescript - Vuex(vuex-typex)突然抛出未知动作类型
- javascript - 错误:当我打开下一个渲染页面时,找不到模块“../core-js/object/define-property”