iOS 13.0 -- No.
iOS 13.1 and newer, yes. They did add a way for this.
The property got moved from an instance property to a class property. You're seeing the prompt when you initialize a CBManager subclass, which is needed to access the authorizationStatus instance property. Refer to this API change:
https://developer.apple.com/documentation/corebluetooth/cbmanager/3377595-authorization?changes=latest_majorBefore you construct your CBManager class, do CBManager.authorization. Then handled the case that it is not authorized and present your user with what ever onboarding experience you choose.
In my workout app, I connect to Heart Rate Monitors (and some cycling sensors too in a future update!). For my user experience, I live with it for iOS 13.0. iOS 13.1 and newer, I only setup my scanner in my AppDelegate if the user has already faced the prompt (i.e. auth status != .notDetermined). Since watchOS 6 wasn't released when iOS 13.0 was, they managed to get the better API in for watchOS 6.0! Yay!
Code Block func didFinishLaunching .... |
|
... |
|
if #available(iOS 13.1, *), CBManager.authorization != .notDetermined { |
let sensorManager = BluetoothSensorManager.shared |
sensorManager.configure(healthStore: .shared) |
sensorManager.loadSavedSensors() |
} |
|
... |
} |
So for iOS 13.0, if you can manage lazily instantiating your CBManager subclass until the exact moment you need it--do so. That is more or less the only workaround you have for iOS 13.0.
For best practices, many WWDC videos that talk about API that use a permission model, defer, defer, defer. Don't ask for permission until you need it. Check out the new precise location API for iOS 14 or the WWDC 2019 Bluetooth video.
Regards