IBeacons Broken on iOS 10.0.2?

How is everyone doing with iBeacons on iOS 10.0.2? Hopefully better than me !:-)

Update. The equipment used for testing is two iPhones. IPhone 5S (A1533) and iPhone 7 (A1778)

The quick version 2.x of the code below can be used on iPhone to advertise a simple iBeacon on iOS versions 9.x; Today, the same code updated for fast version 3 and running on iOS 10.0.2 is not published at all.

I have reduced the code to a very simple helper class and a viewcontroller, which I think should adequately demonstrate the problem. Please note that there is only one button in the storyboard related to starting / stopping iBeacon ads.

I launched the application on iPhone 5 and iPhone 7 with iOS 10.0.2. For testing, I created my own scanner (sniffing for a specific proximity UUID), and when this did not work, I tried the more general iBeacon to detect applications such as Estimote and LightBlue.

Sigh - nothing sees iBeacon.

Thoughts? Apple's developer forums mention issues reported by iBeacons in 10.x, but nothing is as simple as that, as far as I can tell.

Thanks a lot ...

- - - iBeaconConfiguration.swift - - - - - - import Foundation class iBeaconConfiguration { static let uuid = UUID(uuidString: "F34A1A1F-500F-48FB-AFAA-9584D641D7B1")! private init() {} } - - - ViewController.swift - - - - - - import UIKit import CoreLocation import CoreBluetooth class ViewController: UIViewController, CBPeripheralManagerDelegate { @IBOutlet weak var btnAction: UIButton! let UUID: UUID = iBeaconConfiguration.uuid var beaconRegion: CLBeaconRegion! var dataDictionary = NSDictionary() var bluetoothPeripheralManager: CBPeripheralManager! var isBroadcasting = false override func viewDidLoad() { super.viewDidLoad() bluetoothPeripheralManager = CBPeripheralManager(delegate: self, queue: nil, options: nil) } @IBAction func switchBroadcastingState(_ sender: AnyObject) { if !isBroadcasting { if bluetoothPeripheralManager.state == CBManagerState.poweredOn { let major: CLBeaconMajorValue = 123 let minor: CLBeaconMinorValue = 456 beaconRegion = CLBeaconRegion(proximityUUID: UUID, major: major, minor: minor, identifier: "com.rdz.bcast") dataDictionary = beaconRegion.peripheralData(withMeasuredPower: nil) bluetoothPeripheralManager.startAdvertising(dataDictionary as? [String : Any]) btnAction.setTitle("Stop", for: UIControlState.normal) isBroadcasting = true } } else { bluetoothPeripheralManager.stopAdvertising() btnAction.setTitle("Start", for: UIControlState.normal) isBroadcasting = false } } func peripheralManagerDidStartAdvertising(_ peripheral: CBPeripheralManager, error: Error?) { print ("peripheralManagerDidStartAdvertising()") if error != nil { print(error) } } func peripheralManager(_ peripheral: CBPeripheralManager, didReceiveRead request: CBATTRequest) { print ("peripheralManager(...didReceiveRead)") } func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) { var statusMessage = "" switch peripheral.state { case CBManagerState.poweredOn: statusMessage = "Bluetooth Status: Turned On" case CBManagerState.poweredOff: if isBroadcasting { switchBroadcastingState(self) } statusMessage = "Bluetooth Status: Turned Off" case CBManagerState.resetting: statusMessage = "Bluetooth Status: Resetting" case CBManagerState.unauthorized: statusMessage = "Bluetooth Status: Not Authorized" case CBManagerState.unsupported: statusMessage = "Bluetooth Status: Not Supported" default: statusMessage = "Bluetooth Status: Unknown" } print("Bluetooth Status: \(statusMessage)") } } - - - END - - - - - 

(Sorry for the errors of any code format.)

+5
source share
2 answers

Many people report bluetooth problems on iOS 10, but the problem is not universal.

Testing with 10.0.2 (14A456) on the 6th generation iPod touch model mkh22ll / a, I can successfully scan beacons and transfer iBeacon using Find iOS App . This is written in Objective-C, but uses the same APIs as you. You can try the same application on a problem device and see if you have problems.

Testing another application written in Swift 3 on one device (the application transmits and receives iBeacon packets), I checked that it successfully receives iBeacon packets and sends them too.

The bottom line is that the transfer and discovery of iBeacon on iOS 10 works great on some devices.

I suspect that bluetooth problems with iOS 10 occur only with some iPhone hardware models (and maybe only on certain devices of these models) that have slightly different bluetooth hardware chipsets.

A few things that can help troubleshoot:

  • Disconnect and enable Bluetooth again.
  • Reboot the device. (I know this sentence is Lame.)
  • Try performing super simple operations, such as scanning other connected Bluetooth devices in the settings, and see if you can see other devices, such as your Mac or bluetooth speakers. If this simple Bluetooth task does not work, iBeacon will not work.
  • Check Find the application described above. This can fix the encoding problem.

Please update the question on your hardware device.

+3
source

I also tried monitoring the iBeacon Region using iPhone 7 (A1778) and iPhone 6S (A1688). I also feel that didEnterRegion and didExitRegion never run on iPhone 7. The reason for this may be that Apple has reset the iBeacon micro-location on iPhone 7.

According to the technical specifications, “iBeacon microlocation” is no longer displayed for iPhone 7. Here are the technical specifications of iPhone 7: https://support.apple.com/kb/SP743?locale=en_US Here are those from iPhone 6S: https: // support .apple.com / kb / SP726? locale = en_US

I tried to restart, and actually it helps it work while the application is running in the foreground. Regional monitoring in the background does not work at all. It also does not work if you return to the forefront after the application has been in the background.

0
source

Source: https://habr.com/ru/post/1258231/


All Articles