【问题标题】:Can I use code to check if the receiver of airdrop has an application installed?我可以使用代码检查空投的接收者是否安装了应用程序吗?
【发布时间】:2019-01-07 07:09:33
【问题描述】:

我通过我的应用程序中的 UIActivityViewController 与空投共享 .zip 文件。

@IBAction func shareAction(_ sender: Any) {
    let newFileURL = NSHomeDirectory() + "/Documents/test.zip"
    let url = NSURL(fileURLWithPath: newFileURL)
    let shareItems = [url] as [Any]


    let ac = UIActivityViewController(activityItems: shareItems as [Any], applicationActivities: [])
    ac.excludedActivityTypes = [UIActivity.ActivityType.assignToContact, UIActivity.ActivityType.addToReadingList]


    if(UIDevice.current.userInterfaceIdiom == .pad) {
        let popover = ac.popoverPresentationController
        popover?.sourceView = shareButton
        popover?.sourceRect = CGRect(x: 150, y: 40, width: 0, height: 0)
    }
    present(ac, animated: true, completion: nil)

    func completionHandler(activityType: UIActivity.ActivityType?, shared: Bool, items: [Any]?, error: Error?) {
        if (shared) {
            print("Share Succeed!")
        }
        else {
            print("Share failed!")
        }
    }
    ac.completionWithItemsHandler = completionHandler
}

我想知道: 接收方使用什么应用程序打开我发送的文件? / 接收器是否安装了我的应用程序? 这可以实现吗?

【问题讨论】:

    标签: ios


    【解决方案1】:

    这是不可能的。 如果您想确保文件仅由您的应用程序打开,您需要分配一个唯一的文件扩展名并让您的应用程序处理该扩展名。 您仍然可以在内部使用 zip 格式。

    【讨论】:

    • 提前致谢。我已在应用程序中重命名接收到的“.zip 文件”,并用我的应用程序处理了唯一的文件扩展名(例如:fileName.zip-> fileName.myAppUseZip 扩展名),但是当设备没有安装我的应用程序时,系统会弹出: "'fileName' 想要共享一个需要 App Store 应用程序的文件。"附上三个选项:1.Get App 2.Save to iCloud Drive 3.Cancel
    • @user10877689:我不知道。我建议您针对该主题创建一个新问题。
    猜你喜欢
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-16
    • 2011-10-14
    • 2017-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多