I have read CLLocationManager kCLErrorDomain Codes? as well as Apple Docs
I check to make sure ranging is available before calling startRangingBeaconsInRegion: and I am also checking if ranging is available while in the locationManager:rangingBeaconsDidFailForRegion:withError: method. Returns true both times.
When I get the set of monitoredRegions, my beacon is in the set (so registering for monitoring is working).
I have read that error 16 can mean ranging is unavailable, bluetooth could be off, location services could be off, airplane mode could be on, I have checked them all and all are available and running (obviously not in airplane mode).
What could be causing the ranging to fail, every time I run the app?
It seems that I started to face this issue after I updated my device to iOS 7.1 (iPhone 5S). rangingBeaconsDidFailForRegion: gets called with error.domain equal to #"kCLErrorDomain" and with error.code as kCLErrorRangingUnavailable (16) (even though Airplane mode is not on and Bluetooth is up and running).
I followed davidgyoung's advice to just boot (I did a hard boot pressing Home + Power until the device shuts down and displays the Apple logo, but also a normal boot works) the device, and now it seems to work correctly.
This appears to be a bug in iOS 7.1 and iOS 7.1.1, see here https://stackoverflow.com/a/22949187/1461050. The only workaround - for now - is to reboot the device.
Apple has now released iOS 7.1.2, which should fix this problem (awaiting for confirmation).
Just to eliminate any possibility that it could be something in your code, try a reference app like my Locate for iBeacon. If it also does not work, you probably have an OS or hardware problem.
To troubleshoot this, first reboot your phone and try again. Then try pairing to a regular Bluetooth device (headphones, Mac, etc). If regular Bluetooth pairing works, it may be a Bluetooth LE issue.
Your iOS device must be either an iPhone 4s+ or an iPad 3+ (needed for BLE).
The problem is closely related to the CoreBluetooth Unknown Error 1309.
In some circumstance, seems that the CoreBluetooth Stack become corrupted and the only solution is to reboot the device.
There're plenty of users that are reporting such behaviour. We've fired a bug to Apple Radar and we're waiting for response.
You can also report the problem to Apple Radar so that they will notice this bug.
Related
I am developing an appleTv app with Xcode.
Every time, I leave appleTv untouched for a long period of time (an hour or so), it gets disconnected:
This is the error:
Failed _shouldMakeReadyForDevelopment check even though device is not
locked by passcode.
allowsSecureServices: 1. isConnected: 0. Platform:
DVTPlatform:0x7fd21e57e7a0:'com.apple.platform.appletvos':<DVTFilePath:0x7fd21e57f5a0:'/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform'>.
DTDKDeviceIdentifierIsIDID: 0
So when I try to build, I get stuck in here:
This is making developing a tvOS app near impossible, since so much of my time is spent debugging why the appleTv is not correctly paired/connected to my MAC.
NOTE1: I've tried unpairing&pairing again, restarting the appleTv and the MAC, resetting the appleTv and still no result.
NOTE2: I have the latest Xcode version installed.
NOTE3: Similar questions have been asked on StackOverflow but none of them tackled the tvOS problem in particular. And I have also tried their proposed solutions.
NOTE4: AppleTv is connected to my MAC through wifi.
I ran into this and found that leaving Xcode on the "is not connected" dialogue and turning the Apple TV off and on fixed it. (I have both my mac and AppleTV connected to the same switch via ethernet.)
I also have a factory-reset Apple TV with no PIN. It's possible there's some configuration that prevents this from working for you. Maybe a factory reset would fix it?
Edit: After developing with the Apple TV 4K UHD for a month, I have frequent issues like this, but not always the same. Usually I can't connect and need to re-pair (even though it's already paired). Sometimes pairing appears to succeed, but the device isn't usable. Sometimes even restarting my mac and tvos fail to resolve the problem.
I needed to run a long test to see what's making my app crash. So I set the Mac to not sleep and I ran the app on the iPhone connected via USB overnight. In the morning, I found that the iPhone had disconnected during the night.
I looked for in Console and Xcode for device logs and I found there were none at all on the phone, therefore no history of what happened during the night. Logs began after the moment I reconnected the phone to the Mac.
I downloaded the app container and found no useful evidence of what happened.
iOS is 12.4 and Xcode is 10.3.
What can be done to ensure there is some evidence of what caused the crash? Other than filling the app with fprintf's going to a custom log file. Also I am using Fabric.
Do the same thing again, but this time with a camera looking at the PC. Maybe you can grab some evidence from the recording next day. Modern solutions for modern problems.
Go to Settings -> Touch ID and Passcode
Check if USB Accessories has been turned off. Your device may have disconnected then failed to reconnect due to this feature restricting access to the device if it is disconnected for more than an hour.
Change this setting, replace your cable or use a different USB port then try running it again.
I am making an app that requires consistent wifi connection. The problem is that when the wifi is off and I turn on the app nothing happens, even though I have activated the UIRequiresPersistentWiFi flag. Also when the screen locks, and I go to the app after unlocking, it also can't use the wifi. The only solution that I have found for this problem is the activation of UIRequiresPersistentWiFi, which clearly doesn't work in my app, or I am not doing it right. So does anyone have any idea what could be wrong?
UIRequiresPersistentWiFi doesn't force the device to connect to WiFi when the app is launched, it only specifies that an existing WiFi connection should be kept open for the duration your app is running. The default behaviour is for iOS to drop its WiFi connection after 30 minutes to conserve battery life.
See the documentation for more detail.
My app uses BLE (Bluetooth 4) to connect to a physical peripheral.
My users and I have repeatedly encountered a bug where, at some point, the app stops connecting to the peripheral - you can see an indication that the BLE peripheral is discovered and the connection was established, but then few seconds after, the connection is dropped.
Things go back to normal only after restarting the iDevice.
I’ve done a very long work on checking it and researched this issue thoroughly, until I got to the conclusion that this must be a bug in iOS (tested with 7.1, but probably occurs on 8.0 as well).
My tests and findings:
Occurs with every BLE supporting iDevice.
Occurs with both my own BLE peripheral and with other 3rd party BLE products, both known to work perfectly in normal cases.
It can sometimes work well for even 50 launches, but then eventually it’ll fail.
Network & factory settings reset did not help.
Tested and occurred with various applications: ##
My own app.
Clean new Xcode project that’s only scanning for peripherals and trying to connect to the first and only discovered peripheral.
Apple’s BLE example app: Health Thermometer (with relevant modifications since I don’t have this particular peripheral).
3rd party apps, including the generic LightBlue.
Important note: Every one of the options above worked perfectly for a while (multiple launches), at some point suddenly stopped and then worked again after a restart of the device.
The connection procedure seems to fail when trying to discover the peripheral’s services - i.e. it gets discovered and connected normally, but when initiating discovery of services, it stops responding (didDiscoverServices isn't called).
I have of course tried many approaches found online with no luck.
Can anyone shed some light on this problem?
Is it a known issue?
Was it fixed in a recent iOS update?
Is it going to be fixed?
You can imagine the negative affect such an issue has on my users’ experience, as BLE connection is essential to the product.
I'll appreciate your advice and suggestions on how to solve it.
Thanks!
Update:
Apple responded to my tech support request:
Bottom line(s):
They said they had fixed some BLE related bugs in iOS 8 and urging us to test if it still happens in iOS 8.
They said to start with that and if not, try to diagnose the problem with a utility app they provide.
So far for me it didn't happen with iOS 8, but on the other hand I can see posts about other Bluetooth issues, that are not necessarily related but who knows.
Full answer:
I’m responding to your finding that you and your customers find that
after some point of use, iOS BLE fails to maintain a connection. You
indicate that the problem was identified with iOS 7.1. There have been
issue regarding iOS BLE which have been reported and have been fixed
with iOS 8.0. To best determine whether your issue has been addressed,
of course the simplest means would be to install iOS 8 and to see if
the issue can be replicated. However, as you report that you can
replicate the problem on your deivce with iOS 7.1 the first thing
would be to obtain the Bluetooth Server profile, install it to your
deivce, replicate the problem, then obtain a BLE Server log when the
problem occurs. The profile will have the BLE server report additional
logging details which can help to report issues that the server
encounters. We can see if the issue is one which has been reported
previously. Something to consider is that for all new bug report
issues, Core Bluetooth engineering is requesting that all issues be
regressed with the currently shipping version of iOS - that is 8.0.
For customers with iOS 7.x, there will be no more iOS 7 updates - all
software fixes and bug fixes will be with iOS 8. For this reason, only
issues which are reported with iOS 8 will be investigated. You can
obtain the BLE server profile from the Apple Developer bug report web
page https://developer.apple.com/bug-reporting/ios/bluetooth/. The
instructions for installing the profile and capturing the log, are
presented on the web page. If you capture a log with iOS 7.x, you can
send it to me for review. However, this will be somewhat of an
academic exercise - to know if iOS solves the issue, or whether it
persists, we will need to see if the issue occurs under iOS 8.
Something to keep in mind, once you update a device to iOS 8, you will
not be able to restore it to a previous version. I’m happy to
review your results. If however, the problem persists under iOS 8,
it’s best to submit a bug report to get Core Bluetooth engineering’s
attention on this matter. You can submit a bug report using the Apple
Developer bug report web page. - http://bugreport.apple.com
So it looks like the problem is solved with recent iOS update (either 8.0 or 8.1).
Most of the time, the app we are coding works quite well with our BLE peripheral. Often for iPhone 5S users the device gets in a funk and whenever we scan for services, the didDiscoverServices: delegate method is never called. Rebooting the device or deleting all settings (General -> Reset -> Reset all settings) fixes the problem temporarily.
Once the device exhibits this problem, even other apps (eg. LightBlue) are affected; no peripherals are able to discover services until a reboot.
For context, our BLE peripheral does not currently support pairing.
What is causing this problem? Are there any ways to avoid causing the instability? Once it happens, is there a way that the app can recover from it automatically?
Some issues with similar symptoms: App doesn't Discover Services When Reconnecting and Not Scanning for Services in iPad Air
Update: Just FYI, I'm still working on this problem, but something we did caused it to happen way less (therefore it's not really a priority ATM). I don't know what caused the added stability yet.
It's probably an iOS bug
1) Enable bluetooth logging on your device
https://developer.apple.com/bug-reporting/ios/bluetooth/
2) Use a packet sniffer to observe the connection between iOS and BLE peripheral