NFCTagReaderSession“缺少所需的权利”

2024-02-24

我正在深入研究 iOS 13 的新 CoreNFC 功能,并且正在努力让 NFCTagReaderSession 正常工作。设置我的权利并实例化 NFCTagReaderSession 和委托后,我尝试通过调用来启动会话nfcTagReaderSession?.begin()。我的会话立即因以下错误而失效:

Error Domain=NFCError Code=2 "Missing required entitlement" UserInfo={NSLocalizedDescription=Missing required entitlement}

我按照此处的文档获取了我的权利文件:https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_nfc_readersession_formats https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_nfc_readersession_formats

我还在我的 Info.plist 中添加了适当的“隐私 - NFC 扫描使用说明”。

有人已经让它发挥作用了吗?这只是 Xcode 11 或 iOS 13 的问题吗?

这是我的 ViewController 中的代码:

import UIKit
import CoreNFC

class ViewController: UIViewController {

    var nfcTagReaderSession: NFCTagReaderSession?

    override func viewDidLoad() {
        super.viewDidLoad()

        nfcTagReaderSession = NFCTagReaderSession(pollingOption: [.iso14443, .iso15693, .iso18092], delegate: self)
        nfcTagReaderSession?.begin()
        print("isReady: \(nfcTagReaderSession?.isReady)")
    }
}

extension ViewController: NFCTagReaderSessionDelegate {
    func tagReaderSessionDidBecomeActive(_ session: NFCTagReaderSession) {
        print("Tag reader did become active")
    }

    func tagReaderSession(_ session: NFCTagReaderSession, didInvalidateWithError error: Error) {
        print("\(error)")
    }

    func tagReaderSession(_ session: NFCTagReaderSession, didDetect tags: [NFCTag]) {
        print("\(tags)")
    }
}

这是我的权利文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.developer.nfc.readersession.formats</key>
    <array>
        <string>TAG</string>
        <string>NDEF</string>
    </array>
</dict>
</plist>

我也遇到了同样的问题,但是删除并添加后就消失了近场通信标签读取在能力方面。

我的权利文件有一点不同:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
    </array>
    <key>com.apple.developer.nfc.readersession.formats</key>
    <array>
        <string>NDEF</string>
        <string>TAG</string>
    </array>
</dict>
</plist>

但我不认为就是这样。

另外,您可以尝试修改Apple示例以满足您的需求:https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app https://developer.apple.com/documentation/corenfc/building_an_nfc_tag-reader_app

或者只是删除.iso18092从轮询选项中它会起作用。我认为这个标准需要特定的权利。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

NFCTagReaderSession“缺少所需的权利” 的相关文章

随机推荐

  • 如何搜索 UITableView

    是的 我知道关于这个主题大约有十亿个问题 但它们似乎都链接到有关实现 UISearchBar 或 Apple 文档的相同旧博客文章 我想知道的是 是否有适当的教程来实现 UISearchDisplayController 类来搜索数组 字典
  • 本地数据库,我需要一些例子

    我正在制作一个将在多台计算机上安装和运行的应用程序 我的目标是制作一个与该应用程序一起安装的空本地数据库文件 当用户使用该应用程序时 他的数据库将填充来自该应用程序的数据 您能给我提供以下示例吗 我需要做什么才能让我的应用程序连接到其本地数
  • 路径别名自动导入错误

    当从 Angular 9 应用程序中提供路径别名的文件夹自动导入服务 组件时 我遇到了奇怪的问题 这些是我在中定义的别名tsconfig json paths core app core shared app shared state ap
  • 在嵌入式linux中使用mono作为硬件

    我正在一家公司实习做研究 我在使用 Mono Net 平台的跨平台实现 时遇到一些问题 我的公司设计硬件和软件 我对使用嵌入式linux的了解非常有限 我实习的公司非常注重 NET 但是 Mono 的新发展 他们问自己是否可以将 Linux
  • 错误处理理论?

    大多数有关错误处理的建议都归结为一些提示和技巧 请参阅这个帖子 https stackoverflow com questions 231128 c error handling good sources of example code例如
  • 如何为 android studio 创建一个名为 Kotlin 的新测试文件夹

    Android Studio 3 1 Canary 4 Build AI 171 4444016 built on November 10 2017 JRE 1 8 0 152 release 1012 b01 amd64 JVM Open
  • 如何从Python中的self方法获取self对象名称

    我正在尝试找到一种方法来自动打印对象引用名称print object更具体 假设我有一堂课 class A def init self self cards def str self return a string representati
  • 将 CA 签名的 JKS 密钥库转换为 PEM

    我有一个带有 CA 签名证书的 JKS 密钥库 我需要将其导出为 PEM 格式才能与 nginx 一起使用 我需要以包含整个链的方式进行操作 以便我的客户可以验证签名 如果我做类似的事情 keytool exportcert keystor
  • pip 安装后没有名为 imutils.perspective 的模块

    我正在尝试遵循本教程 该教程需要imtools 看起来我已经安装了这个包 但Python编译器找不到它 这里发生了什么 教程 http www pyimagesearch com 2016 10 03 bubble sheet multip
  • 带 xcframework 的 Flutter 插件仅适用于不在 ios 模拟器中的设备

    我创建了一个颤振插件 通过在 Flutter 中运行示例应用程序 我收到此错误 Error Swift Compiler Error Xcode No such module AusweisApp2 这是我的文件夹结构 podspec 文件
  • 如何处理移动设备发送的图像?

    我的一位同事正在开发一款 iPhone 应用程序 该应用程序将允许用户通过我的 API 在我的网站上发布图像 我正在构建 API 的一部分 用于接受和处理图像 移动开发人员发送的标头如下 Content Disposition form d
  • Simplecursoradaptor 内的自定义文本字体

    我制作了一个使用 SimpleCursoradapter 的应用程序 String from new String title notes image int to new int R id esodaTextView R id amoun
  • Psycopg2 单引号异常

    我在我的应用程序中使用 psycopg2 一切都很好 但是 当我插入数据时包含单引号 然后 python 抛出下面的异常
  • WebDriverException:消息:握手中缺少“marionette Protocol”字段

    我目前正在尝试在本地运行 robotsframework 测试脚本 Ubuntu 12 04 LTS 64 位 我遇到的问题是无法在 Open Browser 中启动 FF 浏览器 以下是我所拥有的设置的详细信息 规格 火狐浏览器 v26
  • 使用 Cookie 的购物车

    我正在尝试使用 cookie 会话制作一个简单的购物车 根据此代码片段 它仅包含 4 个项目
  • Django - 如何将多个参数传递给 url 模板标签

    在我的 urls py 中我有 r P
  • Rstudio 中的 R 找不到 rmarkdown 包

    我第一次尝试在 PC 上的 Rstudio 0 98 953 中使用 rmarkdown 我已升级到最新版本的 R 3 1 1 和 R studio 本问题末尾提供了 sessionInfo 的输出 据我了解 rmarkdown 应该包含在
  • 使用变量访问对象的属性

    如果我有一个对象 具有名称 电话号码等属性 我如何使用变量在 Javascript 中访问这些属性 我想通过执行以下操作来访问 javascript 中的属性名称 object name bob phone number 911 prope
  • powershell 运行 pip

    我想通过 powershell 脚本运行 python 模块升级 第一行有效 但我不知道如何正确读入文件 第二条点线 我收到此错误 Could not find a version that satisfies the requiremen
  • NFCTagReaderSession“缺少所需的权利”

    我正在深入研究 iOS 13 的新 CoreNFC 功能 并且正在努力让 NFCTagReaderSession 正常工作 设置我的权利并实例化 NFCTagReaderSession 和委托后 我尝试通过调用来启动会话nfcTagRead