Comments (17)
Hi @jvanakker
Just initialising CBCentralManager
as far as I know will not prompt for turning on Bluetooth Radio.
You have to set option key CBCentralManagerOptionShowPowerAlertKey
to YES
.
I will mark this as a feature request to create an option to set this somewhere in the SDK.
This is not a big change and it's a reasonable to add it so please expect this in the next SDK release.
from kontakt-ios-sdk.
Any updates?
from kontakt-ios-sdk.
@stoprocent is anybody there? With new iOS 11 buggy bluetooth management, it would be great to check via SDK if bluetooth enabled and so on.
from kontakt-ios-sdk.
Hi @mikestalker, checking if bluetooth is ON has nothing to do with CBCentralManagerOptionShowPowerAlertKey
. We are about to release new SDK next week. Is this option crucial for you ?
from kontakt-ios-sdk.
Hi @stoprocent, i had problem now with BT. I checked it with CBCentralManager and CBCentralManagerOptionShowPowerAlertKey, but it returned in centralManagerDidUpdateState "CBManagerState.poweredOff". BT was enabled, i've rebooted device, cleaned project, reinstalled app, but no luck. And than "Allow New Connections" appeared in the Bluetooth settings page. And only after i tapped it - CBCentralManager said to me that BT is poweredOn.
So after updating to iOS11 there are a lot of problems related to BT (https://www.asurion.com/connect/tips-and-tricks/new-features-ios-11-update/) and it would be great if developers can just ask SDK if BT is ON and do some call to show system alert with "go to settings button".
from kontakt-ios-sdk.
@mikestalker Are you using NSBluetoothPeripheralUsageDescription
?
Have a look here https://developer.kontakt.io/ios-sdk/quickstart/installation/#first-steps-after-installation under Bluetooth usage
from kontakt-ios-sdk.
@stoprocent yep, i have this property in my info.plist
from kontakt-ios-sdk.
@mikestalker SDK 1.5.1
is up now. Can you try using it?
There is a option to set CBCentralManagerOptionShowPowerAlertKey
.
Have a look here: http://kontaktio.github.io/kontakt-ios-sdk/Documentation/html/Classes/Kontakt.html#//api/name/setCentralManagerPowerAlert:
from kontakt-ios-sdk.
@stoprocent ok. I set this key and what is next? Now in my project to check BT state and/or show alert i use this code
self.bCentralManger = CBCentralManager(delegate: self, queue: DispatchQueue.main, options: [CBCentralManagerOptionShowPowerAlertKey: withAlert]) self.bCentralManger.scanForPeripherals(withServices: nil, options: nil)
and
func centralManagerDidUpdateState(_ central: CBCentralManager) { switch central.state { case CBManagerState.poweredOff: print("Powered Off") btTurnedOn = false case CBManagerState.poweredOn: print("Powered On") btTurnedOn = true case CBManagerState.unsupported: print("Unsupported") btTurnedOn = false case CBManagerState.resetting: print("Resetting") btTurnedOn = false fallthrough case CBManagerState.unauthorized: print("Unauthorized") btTurnedOn = false case CBManagerState.unknown: print("Unknown") btTurnedOn = false } }
How your solution will help? Does it runs scanForPeripherals
somewhere so alert appears? I set this key and got nothing.
As i wrote before
and it would be great if developers can just ask SDK if BT is ON and do some call to show system alert with "go to settings button".
from kontakt-ios-sdk.
@mikestalker I'm a bit confused what are you trying to achieve but if I'm correct this is the solution you are looking for.
- You use ur old code but before initializing
KTKDevicesManager
set config like this:
// Config
[Kontakt setCentralManagerPowerAlert: YES];
// Your Code
self.kontaktDevicesManager = [[KTKDevicesManager alloc] initWithDelegate:self];
[self.kontaktDevicesManager startDevicesDiscoveryWithInterval:1.0];
-
If central manager state is NOT
.poweredOn
you will get a call to devicesManagerDidFailToStartDiscovery:withError:. Error object will contains central manager state to check or you can read centralState fromKTKDevicesManager
. -
If bluetooth is on and working you will get call to devicesManager:didDiscoverDevices:
Is that ok ?
from kontakt-ios-sdk.
@stoprocent thanks for quick reply. But it's a bit different situation in my case. I use
manager = KTKBeaconManager(delegate: self)
manager.startMonitoring(for: region)
and do not use KTKDevicesManager
from kontakt-ios-sdk.
If you are using KTKBeaconManager
then it's CoreLocation
based so you don't have to check CoreBluetooth
.
from kontakt-ios-sdk.
@stoprocent will function func beaconManager(_ manager: KTKBeaconManager, didRangeBeacons beacons: [CLBeacon], in region: KTKBeaconRegion)
be fired if BT if turned off? On my device - no. Maybe i do something wrong?
from kontakt-ios-sdk.
@mikestalker you should read CoreLocation
or KTKBeaconManager
documentation first.
There is this delegate method: beaconManager:rangingBeaconsDidFailForRegion:withError: .
As far as I can see here this is not an issue with the SDK. If bluetooth is of and you try to range beacons you will receive this error.
from kontakt-ios-sdk.
@stoprocent Ok. I got error "error?.localizedDescription "The operation couldn’t be completed. (kCLErrorDomain error 16.)"". And how it can help me???
One more time. I need show user that "we do not see any beacons because your BT is turned off" and suggest him go to system preferences and turn TB on.
Other developers ( @jvanakker ) and I suggest you to implement this feature in SDK. But you are saying that
If you are using KTKBeaconManager then it's CoreLocation based so you don't have to check CoreBluetooth.
I'm saying that beacons will not be found if BT is off, and you are saying "RTFM, use error delegate method and so on." But still, I need show user SYSTEM ALERT with option "GO TO SYSTEM PREFERENCES".
Summary: no BT is on - show system alert and tell user go to system preferences and turn BT on. User do not cares if
KTKBeaconManager then it's CoreLocation based so you don't have to check CoreBluetooth.
from kontakt-ios-sdk.
@mikestalker I'm confused right now and I don't think I'm able to help you. It looks like you are not familiar with basic objects like Error
or NSError
.
You said:
Ok. I got error "error?.localizedDescription "The operation couldn’t be completed. (kCLErrorDomain error 16.)"". And how it can help me???
Error object is built out of domain and code and in my last comment I said look at THIS.
case rangingUnavailable = 16
If you would look in documentation you would see that error code 16 translates to:
This might happen if the device is in Airplane mode or if Bluetooth or location services are disabled.
To complete what you are looking for just implement beaconManager:rangingBeaconsDidFailForRegion:withError:
check if error code is equal 16
and display message to the user. So simple ...
I have provided you with 2 different solutions.
- Check
CoreBluetooth
state withKTKDevicesManager
- Use
KTKBeaconManager
If this is not enough I'm not sure if I can be of any further help.
from kontakt-ios-sdk.
@mikestalker what @jvanakker was asking for was different and again I would recommend you to stop and go trough this topic and read carefully each comment.
from kontakt-ios-sdk.
Related Issues (20)
- didRangeBeacons wrongly detecting beacons
- Burst Mode not working for Beacon Pros
- Monitoring region not working in example app
- Xamarin Bindings
- KTKEddystoneManager centralState is always "unknown" (0) HOT 1
- KontaktIO iOS SDK
- Issue writing beacon with SDK grather than 1.5.1
- Can't monitor Eddystone regions with only a namespaceId HOT 1
- Is there any way to create KTKDevice instance other than using kontakt.io api? HOT 1
- find available Packets
- Update Example to Swift 4 or newer
- not working in iPhone X (os 13.3)
- Changelog not updated
- How to get current battery level of beacon using this SDK on ios?
- KTKDeviceManager delegate method always return empty array
- didChangeLocationAuthorizationStatus delegate does not fire before permission is given
- XCFramework HOT 1
- App stopped receiving any notifications
- pod install error: During installing the S3 bucket returns HTTP 403 error HOT 7
- No way of CLBeacon and KTKNearbyDevice matching
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kontakt-ios-sdk.