How to disconnect from a joinOnce NEHotspotConfiguration? - swift

I'm able to successfully connect to our IOT device's hotspot using NEHotspotConfiguration, however we need to be able to disconnect from the hotspot when they cancel the setup process.
Calling NEHotspotConfigurationManager.shared.removeConfiguration() only removes the config, but if the phone is currently connected to the hotspot this call has no effect and the device remains connected.
How can I disconnect from this hotspot? Seems like it should be simple!

NEHotspotConfigurationManager.shared.getConfiguredSSIDs { configuration in
print("configuration : \(configuration)")
NEHotspotConfigurationManager.shared.removeConfiguration(forSSID: configuration[0])
NEHotspotConfigurationManager.shared.removeConfiguration(forHS20DomainName: configuration[0])
}

I'm seeing the same behavior in iOS 15.2 when connecting to my IoT device: invoking removeConfiguration(forSSID:) does not disconnect an hotspot previously connected with joinOnce = true.
This is contrary to Apple's own documentation on joinOnce, which says:
To disconnect the device from a hotspot configured with joinOnce set
to true, call removeConfiguration(forSSID:)
So, it seems to be a bug in either: a) iOS 15.2, or b) Apple's documentation. I created a bug report here: https://feedbackassistant.apple.com/feedback/9954367, and I will reply when I hear back from them.
I also see this issue was discussed for earlier iOS versions (12.2, 12.3.1) in this developer forum thread without any resolution.

Related

Apple Reachability sample doesn't work in background mode

I've seen that there's a lot of entries in the forum about Apple's Reachability Class, but I haven't seen a solution for this one.
I'm developing a VoIP app that needs to detect connectivity changes in background mode and real time. SCNetworkReachability API should do the job, but I'm facing some problems...
First of all, I've downloaded Reachability sample code from Apple (v2.2) but I haven't been able to make it work in background mode. It works great if I launch the app on the simulator and plug/unplug de network cable. But if I try on the device, launching the app and then going to background mode for enable/disable wifi, the app isn't been notified at all.
I've set "Application does not run in background = NO" and "Required background modes=App provides Voice over IP services" in the info.plist without success. The Donoho version of this sample code has the same problem.
Second one... I've integrated the Reachability sample code on the VoIP app that I'm developing (Linphone based) and... the connectivity changes are detected on background mode...!!!
Nevertheless, it doesn't work well always:
if I launch the app with wifi on, all the following reachability changes, even in background mode, are detected -> OK
but if I launch the app without wifi off, the app doesn't detect the wifi recovery... -> KO
So, the questions are:
how can I make Apple Reachability sample works in background mode?
and... when Reachability class looks to be working on background mode, why it only works really when the first reachability check finds connection available?
I'm running the apps on iPhone4 with iOS 5.1.1 (maybe some problem with iOS version > 5.0...??)
I've checked too the pointed solution on this thread, but last version of Reachability sample is already taking care of that retain/release issues...
Thanks in advance
I've been around this issue for some days, and finally the problem looks to be closely related with the NSStreamNetworkServiceTypeVoIp connection mode,
Looks like a suspended app only could listen to connectivity changes once it has established an active NSStreamNetworkServiceTypeVoIp connection with the remote server.
That explains why Reachability sample is not responding to the connectivity changes in background mode (no NSStreamNetworkServiceTypeVoIp connection within the app) and why the voip app neither responds if wifi's off on first launch...
So, looks like some kind of workaround will be needed for this one...
This Reachability may help you which also comes with sample code.This notifies you whenever your internet goes down or comes up instantly.

How can i Open Serial Port of Dock connector in iOS 5.0.1

I can successfully open the serial port of iPhone/iPad in lower version than iOs 5. with the use of
open("/dev/tty.iap", O_RDWR | O_NOCTTY | O_ASYNC))
but i got error "Operation not permitted" in iOS 5 .
(I used the Serial Programming for communicating accessory and iPhone)
Is there any one have idea about this.
Thanks.
Since it also doesn't work for me I think Apple blocked serial access on iOS5+. Stefan Esser (#i0n1c on twitter) just had a talk about this at a security conference. I'm waiting for the slides so then we know what happened to serial
Not sure if you got this working, but from what I have read you can not access the iPhone's serial port for communication while your app is in the sandbox. By sandbox, I mean when you click "run" in Xcode and transfer your app to your iDevice the app lives in a sandbox environment. This environment prohibits your app from accessing things such /dev/tty.iap the serial port within the dock connector. One solution I have read is to copy your app /Applications/which is a link to the location /var/stash/Applications.XXXXXX/ which should take your app out the sandbox environment, and give it access to /dev/tty.iap Let me know if this works for you as this is something I am eventually going to have to do with the app I am developing.
I got the same error and was able to solve it by putting the app in the directory where Cydia apps go rather than where Xcode automatically puts it (Found this hint in the second link in this related/identical post).

Apple Push Notifications - When Registering for Notifications no Callbacks are received at all

I've gone through all the steps as specified, am using a dev certificate with APN enabled and am calling registerForRemoteNotificationTypes: with the right flags in my app delegate.
Still, neither application:didRegisterForRemoteNotificationsWithDeviceToken: nor application:didFailToRegisterForRemoteNotificationsWithError: are being called. It looks like the registration request just gets stuck in transit.
What am I doing wrong?
This sounds silly, but it's bit me in the past: double-check your capitalization and parameter types. If a delegate method declaration isn't spot on your method won't get called, and you won't get any kind of warning.
Your best bet is to copy and paste the prototype from Apple's documentation.
Try your App on another device. If it works there...
I have the same Problem with one iPhone 3G (no jailbreak, no unlock). It somply dos not work with that phone. I tried updating to a newer iPhone OS. I tried a factory reset. It does show the confirmationscreen and it records the answer in the Settings. But neither application:didFailToRegisterForRemoteNotificationsWithError nor application:didRegisterForRemoteNotificationsWithDeviceToken are ever called.
The same App works on all other tested devices (ipods, iphones). This iPhone 3G does also not receive PNs for other apps.
PNs also did not work for one Jailbroken Classic iPhone.
It might be that your device is simply not behaving correctly. Try a different device.
I had this problem too and it was because of bad certificates, app id, provision profile...
Make sure that:
1, Correct certificates are installed on client AND server
2, Make sure that you have selected correct provision profile in your project settings. REMEMBER App ID in your provision profile has to be specific(not ending with *) and last part of this App ID has to match name of your application exactly and it is case sensitive. so iv your app is called myApp then your app id has to be SOMENUMBERScom.yourcompany.myApp
Just an idea...
I had the same problem and solved it by disconnecting from the cellular network. Seems to be some problem when both wireless and 3G are on concurrently.
I found out that PUSH notifications require port 5223 open in your network (if you are using WIFI), or otherwise, a cellular data connection.
I encountered the same problem in my home network, and had to open the port manually in the wireless router.

Apple Push Notification Service - notification messages aren't sent to iphone device

I constructed provider code with using C# and it was able to send notification messages to iphone devices successfully. But since yesterday, it hasn't worked. Also it seems to connect APNS successfully and send notification message. Unfortunately, no notification message is received by iphone device. I controlled internet connection and device token of iphone device. What else can I do? Thanks in advance...
I dont have enough rep to comment on the question so typing out answer - Please add more details and I will edit my answer.
Is this in a developer / testing environment and are you using an ad hoc profile to install the application on the iphone devices?
Did you check if the device token has changed and that you are using the new/ correct token in the C# code?
Do provide more details of your problem.
Crazywood, I don't have a solid answer for you but I can tell you I'm in the same boat as you.
There are times when all my notifications go through and times when none of them seem to.
One guess is that not all notifications are sent. According to the docs, in production remote notifications are not guaranteed to be received by the client. My guess is that this is also the case for the sandbox.
-------- EDIT ------
I went through the trouble shooting list (http://developer.apple.com/library/ios/#technotes/tn2010/tn2265.html) and came across this:
The device may have lost its persistent connection to the push service and can't reconnect. Try quitting the app and relaunching it to see if registration completes the next time. (On iOS 4 and later on devices that support multitasking, you will need to force quit the app from the recents list.) If the registration does not complete, iOS has been unable to re-establish the persistent connection. You can troubleshoot this as described in the previous two sections.
I restarted the app and it made no difference. Then I rebooted my phone. That seemed to do the trick.

Unexpected error while trying to connect to iPhone

Your mobile device has encountered an unexpected error(0xE800002E)
Try disconnecting and powering off the device;then power the device on and reconnect it.
I received these message so many times. How can I fix it?
Although you can see this error when you connect in XCode, it is not actually an Xcode defect.
See this thread at Apple's discussion boards. You basically need to reset you phone. I'm not sure but Ithink there may be a link between seeing this error and using your phone for development but I have no concrete evidence.
I find that if I plug my device in and its set to automatically run iPhoto - then you must let iPhoto load and let it try to sync photos before you quit it. Then you should be able to use XCode to load an application on to your phone.
If you do get the error - unplug the device, turn it off and then back on, and that usually clears up the problem