iOS 8.2 UIRequiresPersistentWiFi not working - ios

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.

Related

iPhone disconnected USB connection overnight and there are no system logs

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.

How to debug an app on iPhone without internet

I'm using Xcode 10.1, and I don't have a checkbox whether I want to connect through network or not on my device page (which was there in Xcode 9 and Xcode 10 beta). Search "connect via network xcode" on google images if you don't know what I mean.
However, I must debug the offline flow of my app (which is written in React-Native btw). Not just no-internet-connection, but turning off wifi and mobile-data, which will trigger a status change. By using the developer settings of the iPhone, I can make every call fail (100% loss), but cannot change the internet-status of the phone.
So I want the debugger to stay connected and either be able to:
debug the old-school way through the cable (if I turn off internet now, I get a red error screen and nothing is possible anymore), so I can disable wifi and mobile-data,
or simulating that status change on the phone.
Btw, I cannot use a simulator, since the app requires Bluetooth.
Thanks in advance!
Edit:
The checkbox is not there for older iPhone devices. With iPhone 7s, I do see the checkbox "connect via network". But enabling or disabling does not change the fact that your iPhone needs internet to debug. If I disable internet on the phone I get the following error:
Ok, I've found the problem. We are testing on a iPhone5, which is no longer officially supported by Apple. Which means that Apple has decided to cut features for iPhone5 so you would buy a new one (wonderful strategy =/). Hence debugging with a cable is no longer supported on iPhone5.
We tested with a iPhone6 from a colleague, and everything works fine.
Edit:
Altough the checkbox is there, and I can disable wifi for connection... The moment I turn off internet on the phone, the app crashes and says: "Runtime is not ready for debugging: make sure packager runtime is running"... so no solution yet...

ios8.3 bluetooth lost connection every 30s

Recently, I develop a BLE app in iOS8.3.
But, I found a terrible question.
When I connect the BLE device with iPhone, almost every 30s, the connection is lost. After I restart the iPhone, the problem is disappear.
Who maybe explain this?
Thank all.
Here is your answer
Try switching Airplane mode on for 30 seconds, then turn it off and try connecting again.
Try holding down the home button and the Sleep/Wake button until your device restarts.
Turn your router off for 30 seconds and then switch it on again.
Go to Settings > General > Reset > Reset Network Settings and then setup your Wi-Fi, Bluetooth again.
Try chaining the channel on your router and check the rest of the settings.
Make sure that your router firmware is up to date.
Try a factory reset of your iPhone.

locationManager:rangingBeaconsDidFailForRegion:withError: kCLErrorDomain 16

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.

Some iOS 4.2 devices shutting down WiFi early?

I write an app that requires a persistent WiFi connection, and to facilitate that connection being as persistent as possible, I have UIRequiresPersistentWifi set to yes in my Info.plist, and I recommend leaving the app 'open' when the user presses the the hold button.
However, on iPod touches (I have a 2G one and a 4G one for testing) running iOS 4.2.1, the device seems to shut down the WiFi connection much earlier after the device is put to sleep than it did on earlier iOS versions. I think it's on the order of 60 seconds.
I don't believe Apple has made any firm commitments on how it handles powering down network connections, but I was under the impression it was longer, intended to be longer, and it was something we could rely on. Does anyone have any input on this?
It appears after some reading/research, it looks like Apple's philosophy is that the WiFi network shouldn't be relied upon: "Note: Note that even when UIRequiresPersistentWiFi has a value of true, it has no effect when the device is idle (that is, screen-locked). The application is considered inactive, and although it may function on some levels, it has no Wi-Fi connection." - (from the iOS Application Programming Guide).
I'm guessing I'm seeing the different behavior on an iPhone because, also, in the iOS Application Programming Guide - "Connect to the network using the Wi-Fi radios whenever possible. Wi-Fi uses less power and is preferred over the cellular radios."

Resources