连接Lightning kBD或Smart KBD后没有EAAccessoryDidConnectNotification和EAAccessoryDidDisconnectNotification

时间:2022-03-16 13:50:26

I could not get these two notifications EAAccessoryDidConnectNotification and EAAccessoryDidDisconnectNotification after connecting Lightning kBD or Smart KBD with my APP. But it worked on iOS9.3 with my code as below,

将Lightning kBD或Smart KBD与我的APP连接后,我无法获得EAAccessoryDidConnectNotification和EAAccessoryDidDisconnectNotification这两个通知。但它在iOS9.3上工作,我的代码如下,

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_accessoryDidConnect:) name:EAAccessoryDidConnectNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_accessoryDidDisconnect:) name:EAAccessoryDidDisconnectNotification object:nil];
[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];

What's the cause?

原因是什么?

P.S.: I got this following message in the logs. Couldn't find the "com.apple.private.externalaccessory.showallaccessories" entitlement

P.S。:我在日志中收到以下消息。找不到“com.apple.private.externalaccessory.showallaccessories”权利

5 个解决方案

#1


0  

I deleted the "iOS Team provisioning profile: *" in Xcode->preferences->accounts->-> view details.

我在Xcode-> preferences-> accounts - > - > view details中删除了“iOS Team provisioning profile:*”。

As soon as you delete that profile a fresh copy is downloaded. Since then I don't see this "Couldn't find the com.apple.private.externalaccessory.showallaccessories entitlement" anymore. I am guessing this entitlement is now in the "iOS Team provisioning profile: *". If your bundle ID is present in other "iOS Team provisioning profile" then I would recommend to delete those provisioning profile too.

删除该配置文件后,将立即下载新的副本。从那时起,我再也看不到“无法找到com.apple.private.externalaccessory.showallaccessories权利”。我猜这个权利现在在“iOS团队配置文件:*”中。如果您的捆绑包ID出现在其他“iOS团队配置文件”中,那么我建议您删除这些配置文件。

#2


0  

It seems the issue is well known in iOS 10(beta) versions as we don't have stable release available, This seems to be resolved in stable release of iOS 10. Its also raised on Apple Developer Forum as well, but no concrete solution.

似乎这个问题在iOS 10(beta)版本中是众所周知的,因为我们没有可用的稳定版本,这似乎在iOS 10的稳定版本中得到了解决。它也在Apple Developer Forum上提出,但没有具体的解决方案。

Though i tried a few different things to fix this, but ended up doing this, which worked:

虽然我尝试了一些不同的东西来解决这个问题,但最终做到了这一点,这有效:

  1. Clean
  2. 清洁
  3. Clean Build Folder
  4. 清理构建文件夹
  5. Delete and re-link ExternalAccessory.framework
  6. 删除并重新链接ExternalAccessory.framework
  7. Delete app on iOS device
  8. 删除iOS设备上的应用
  9. Build and run
  10. 建立并运行

If this doesn't work, try deleting and generating a new provisioning profile for your app.

如果这不起作用,请尝试删除并为您的应用生成新的配置文件。

#3


0  

Here is my experience. On Xcode 8.1 I can successfully build an old NIB-based Apple project (EADemo) and run it on iOS 10.1.1 device. It works fine with my Bluetooth accessory. Then I renamed the project folder and completed the porting to a Storyboard-based project. Running the app on the same iPhone the EA Session crashes and I get the error log:

这是我的经历。在Xcode 8.1上,我可以成功构建一个旧的基于NIB的Apple项目(EADemo)并在iOS 10.1.1设备上运行它。它可以与我的蓝牙配件一起使用。然后我重命名了项目文件夹并完成了移植到基于Storyboard的项目。在同一个iPhone上运行应用程序EA会崩溃,我收到错误日志:

2016-11-29 17:04:00.804421 K5Demo[430:69578] Couldn't find the "com.apple.private.externalaccessory.showallaccessories" entitlement 2016-11-29 17:04:04.736780 K5Demo[430:69578] ERROR - opening session failed as protocol (null) is not declared in Info.plist

2016-11-29 17:04:00.804421 K5Demo [430:69578]无法找到“com.apple.private.externalaccessory.showallaccessories”权利2016-11-29 17:04:04.736780 K5Demo [430:69578]错误 - 由于协议(null)未在Info.plist中声明,因此打开会话失败

For the two cases the Info.plist file is the same, and also the iOS version.

对于这两种情况,Info.plist文件是相同的,也是iOS版本。

#4


-3  

In iOS 10 Apple has two new requirement so that your app can receive EAAccessoryDidConnectNotification and EAAccessoryDidDisconnectNotification notifications, and can list devices via [[EAAccessoryManager sharedAccessoryManager] connectedAccessories].

在iOS 10中,Apple有两个新要求,以便您的应用程序可以接收EAAccessoryDidConnectNotification和EAAccessoryDidDisconnectNotification通知,并可以通过[[EAAccessoryManager sharedAccessoryManager] connectedAccessories]列出设备。

  1. Include a protocolString of the external accessory in your app's UISupportedExternalAccessoryProtocols property list.

    在应用程序的UISupportedExternalAccessoryProtocols属性列表中包含外部附件的protocolString。

  2. Have the external accessory's manufacturer submit to Apple a request for MFi whitelisting of your app.

    让外部配件的制造商向Apple提交您的应用程序的MFi白名单请求。

For debug, only (1) is needed. But your app will not be approved by Apple (probably not even for TestFlight) without (2).

对于调试,仅需要(1)。但是,如果没有(2),您的应用程序将不会被Apple批准(甚至可能不适用于TestFlight)。

#5


-3  

You can try deleting and generating a new provisioning profile for your app.

您可以尝试删除并为您的应用生成新的配置文件。

In iOS 10 Apple has two new requirement so that your app can receive EAAccessoryDidConnectNotification and EAAccessoryDidDisconnectNotification notifications, and can list devices via [[EAAccessoryManager sharedAccessoryManager] connectedAccessories].

在iOS 10中,Apple有两个新要求,以便您的应用程序可以接收EAAccessoryDidConnectNotification和EAAccessoryDidDisconnectNotification通知,并可以通过[[EAAccessoryManager sharedAccessoryManager] connectedAccessories]列出设备。

Include a protocolString of the external accessory in your app's UISupportedExternalAccessoryProtocols property list.

Have the external accessory's manufacturer submit to Apple a request for MFi whitelisting of your app.

For debug, only (1) is needed. But your app will not be approved by Apple (probably not even for TestFlight) without (2).

对于调试,仅需要(1)。但是,如果没有(2),您的应用程序将不会被Apple批准(甚至可能不适用于TestFlight)。

#1


0  

I deleted the "iOS Team provisioning profile: *" in Xcode->preferences->accounts->-> view details.

我在Xcode-> preferences-> accounts - > - > view details中删除了“iOS Team provisioning profile:*”。

As soon as you delete that profile a fresh copy is downloaded. Since then I don't see this "Couldn't find the com.apple.private.externalaccessory.showallaccessories entitlement" anymore. I am guessing this entitlement is now in the "iOS Team provisioning profile: *". If your bundle ID is present in other "iOS Team provisioning profile" then I would recommend to delete those provisioning profile too.

删除该配置文件后,将立即下载新的副本。从那时起,我再也看不到“无法找到com.apple.private.externalaccessory.showallaccessories权利”。我猜这个权利现在在“iOS团队配置文件:*”中。如果您的捆绑包ID出现在其他“iOS团队配置文件”中,那么我建议您删除这些配置文件。

#2


0  

It seems the issue is well known in iOS 10(beta) versions as we don't have stable release available, This seems to be resolved in stable release of iOS 10. Its also raised on Apple Developer Forum as well, but no concrete solution.

似乎这个问题在iOS 10(beta)版本中是众所周知的,因为我们没有可用的稳定版本,这似乎在iOS 10的稳定版本中得到了解决。它也在Apple Developer Forum上提出,但没有具体的解决方案。

Though i tried a few different things to fix this, but ended up doing this, which worked:

虽然我尝试了一些不同的东西来解决这个问题,但最终做到了这一点,这有效:

  1. Clean
  2. 清洁
  3. Clean Build Folder
  4. 清理构建文件夹
  5. Delete and re-link ExternalAccessory.framework
  6. 删除并重新链接ExternalAccessory.framework
  7. Delete app on iOS device
  8. 删除iOS设备上的应用
  9. Build and run
  10. 建立并运行

If this doesn't work, try deleting and generating a new provisioning profile for your app.

如果这不起作用,请尝试删除并为您的应用生成新的配置文件。

#3


0  

Here is my experience. On Xcode 8.1 I can successfully build an old NIB-based Apple project (EADemo) and run it on iOS 10.1.1 device. It works fine with my Bluetooth accessory. Then I renamed the project folder and completed the porting to a Storyboard-based project. Running the app on the same iPhone the EA Session crashes and I get the error log:

这是我的经历。在Xcode 8.1上,我可以成功构建一个旧的基于NIB的Apple项目(EADemo)并在iOS 10.1.1设备上运行它。它可以与我的蓝牙配件一起使用。然后我重命名了项目文件夹并完成了移植到基于Storyboard的项目。在同一个iPhone上运行应用程序EA会崩溃,我收到错误日志:

2016-11-29 17:04:00.804421 K5Demo[430:69578] Couldn't find the "com.apple.private.externalaccessory.showallaccessories" entitlement 2016-11-29 17:04:04.736780 K5Demo[430:69578] ERROR - opening session failed as protocol (null) is not declared in Info.plist

2016-11-29 17:04:00.804421 K5Demo [430:69578]无法找到“com.apple.private.externalaccessory.showallaccessories”权利2016-11-29 17:04:04.736780 K5Demo [430:69578]错误 - 由于协议(null)未在Info.plist中声明,因此打开会话失败

For the two cases the Info.plist file is the same, and also the iOS version.

对于这两种情况,Info.plist文件是相同的,也是iOS版本。

#4


-3  

In iOS 10 Apple has two new requirement so that your app can receive EAAccessoryDidConnectNotification and EAAccessoryDidDisconnectNotification notifications, and can list devices via [[EAAccessoryManager sharedAccessoryManager] connectedAccessories].

在iOS 10中,Apple有两个新要求,以便您的应用程序可以接收EAAccessoryDidConnectNotification和EAAccessoryDidDisconnectNotification通知,并可以通过[[EAAccessoryManager sharedAccessoryManager] connectedAccessories]列出设备。

  1. Include a protocolString of the external accessory in your app's UISupportedExternalAccessoryProtocols property list.

    在应用程序的UISupportedExternalAccessoryProtocols属性列表中包含外部附件的protocolString。

  2. Have the external accessory's manufacturer submit to Apple a request for MFi whitelisting of your app.

    让外部配件的制造商向Apple提交您的应用程序的MFi白名单请求。

For debug, only (1) is needed. But your app will not be approved by Apple (probably not even for TestFlight) without (2).

对于调试,仅需要(1)。但是,如果没有(2),您的应用程序将不会被Apple批准(甚至可能不适用于TestFlight)。

#5


-3  

You can try deleting and generating a new provisioning profile for your app.

您可以尝试删除并为您的应用生成新的配置文件。

In iOS 10 Apple has two new requirement so that your app can receive EAAccessoryDidConnectNotification and EAAccessoryDidDisconnectNotification notifications, and can list devices via [[EAAccessoryManager sharedAccessoryManager] connectedAccessories].

在iOS 10中,Apple有两个新要求,以便您的应用程序可以接收EAAccessoryDidConnectNotification和EAAccessoryDidDisconnectNotification通知,并可以通过[[EAAccessoryManager sharedAccessoryManager] connectedAccessories]列出设备。

Include a protocolString of the external accessory in your app's UISupportedExternalAccessoryProtocols property list.

Have the external accessory's manufacturer submit to Apple a request for MFi whitelisting of your app.

For debug, only (1) is needed. But your app will not be approved by Apple (probably not even for TestFlight) without (2).

对于调试,仅需要(1)。但是,如果没有(2),您的应用程序将不会被Apple批准(甚至可能不适用于TestFlight)。