GithubHelp home page GithubHelp logo

Comments (17)

stoprocent avatar stoprocent commented on June 30, 2024

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.

mikestalker avatar mikestalker commented on June 30, 2024

Any updates?

from kontakt-ios-sdk.

mikestalker avatar mikestalker commented on June 30, 2024

@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.

stoprocent avatar stoprocent commented on June 30, 2024

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.

mikestalker avatar mikestalker commented on June 30, 2024

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.

stoprocent avatar stoprocent commented on June 30, 2024

@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.

mikestalker avatar mikestalker commented on June 30, 2024

@stoprocent yep, i have this property in my info.plist

from kontakt-ios-sdk.

stoprocent avatar stoprocent commented on June 30, 2024

@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.

mikestalker avatar mikestalker commented on June 30, 2024

@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.

stoprocent avatar stoprocent commented on June 30, 2024

@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.

  1. 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];
  1. 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 from KTKDevicesManager.

  2. If bluetooth is on and working you will get call to devicesManager:didDiscoverDevices:

Is that ok ?

from kontakt-ios-sdk.

mikestalker avatar mikestalker commented on June 30, 2024

@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.

stoprocent avatar stoprocent commented on June 30, 2024

If you are using KTKBeaconManager then it's CoreLocation based so you don't have to check CoreBluetooth.

from kontakt-ios-sdk.

mikestalker avatar mikestalker commented on June 30, 2024

@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.

stoprocent avatar stoprocent commented on June 30, 2024

@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.

mikestalker avatar mikestalker commented on June 30, 2024

@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.

stoprocent avatar stoprocent commented on June 30, 2024

@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.

  1. Check CoreBluetooth state with KTKDevicesManager
  2. Use KTKBeaconManager

If this is not enough I'm not sure if I can be of any further help.

from kontakt-ios-sdk.

stoprocent avatar stoprocent commented on June 30, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.