标签: ios11.1.1

CBCentralManager始终在iOS 11.1.x上返回.poweredOff状态

我正在开发一个BLE项目,因为我启动了CBCentralManager,并扫描可用的设备.我能够扫描并连接可用的BLE外围设备.一切正常,直到我没有在iOS 11.0.x版本上测试过.
当我在iOS 11.1.1或11.1.2上测试时,CBCentralManager总是在启动应用程序时返回我的poweredOff状态.但是,当我打开控制中心,关闭并再次打开蓝牙或激活/停用FlightMode(自动关闭/开启蓝牙).应用程序开始扫描BLE外围设备,一切看起来都很好,直到重新启动app.有没有人在iOS 11.1.x上遇到这样的问题并能够解决这个问题,请帮助解决这个问题.

下面是我检查状态的代码

func initiateCentralManager(){
      manager = CBCentralManager(delegate: self, queue: nil, options: [CBCentralManagerOptionRestoreIdentifierKey : "MyBLECurrentState"]) 
}

 func centralManagerDidUpdateState(_ central: CBCentralManager){
       print("Received CBCentralManager state")
        peripheralArray.removeAll()
        if central.state == .poweredOn {
            print("poweredOn")
        } else if central.state == .poweredOff {
            print("poweredOff")

        }
    }
Run Code Online (Sandbox Code Playgroud)

bluetooth core-bluetooth swift ios11.1.1

4
推荐指数
1
解决办法
1907
查看次数

我的应用程序未显示在共享表中

我在我的应用程序中集成了共享扩展。这是我用于共享扩展的 plist 文件。

<key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>NSExtensionActivationRule</key>
            <string>TRUEPREDICATE</string>
        </dict>
        <key>NSExtensionMainStoryboard</key>
        <string>MainInterface</string>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.share-services</string>
    </dict>
Run Code Online (Sandbox Code Playgroud)

我在 Xcode 中收到警告,如果我使用 Truepredicate,那么苹果将拒绝我的应用程序。所以我尝试添加其他激活规则,如下所述

<key>NSExtensionAttributes</key>
    <dict>
        <key>NSExtensionActivationSupportsImageWithMaxCount</key>
        <integer>1</integer>
        <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
        <integer>1</integer>
    </dict>
    <key>NSExtensionMainStoryboard</key>
    <string>MainInterface</string>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.share-services</string>
    </dict>
Run Code Online (Sandbox Code Playgroud)

但是,如果我删除 Truepredicate 并添加上述规则,我的共享扩展将不再显示。使用 truepredicate 共享扩展可以正常工作。任何人都可以帮助我我应该在这里做什么?我为音乐相关的应用程序集成了共享扩展。

swift share-extension ios11.1.1

2
推荐指数
1
解决办法
1740
查看次数