iOS Question Wireless Connect/Disconnect notification?

MrKim

Well-Known Member
Licensed User
Longtime User
Is it possible to be notified when wireless connects/disconnects?
I just need to be notified so I can turn on/off airplane mode.

Thanks
 

MrKim

Well-Known Member
Licensed User
Longtime User
More information. What are you trying to do?

Am am in a foreign country indefinitely due to Covid (Taiwan - they have no Covid, they keep extending the time we can stay here and there is no sense going back to the US while it is such a mess). Most of the time I am connected to a wireless network with my Android which meets my connectivity needs. I bought an old iphone for development and decided to buy a pay as you go data plane for it with a local phone # so I could be connected when I am out and about.

At least One of the places where I connect wirelessly has issues in some rooms and disconnects so I wind up burning up data from my cheapo plan. I thought I would do a quick and dirty program that would just remind me with a tone to turn on/off airplane mode when I am connected to a wireless network. The situation varies, for example I am connected at my local 7-11 (they are really big here) but it is always a quick in and out so I wouldn't change the setting there, But when I leave the house and will be disconnected from the wireless for a while I want to turn off Airplane mode. When I get home, turn it in again.

If it is possible to turn airplane mode on/off from within my app that would be a bonus - save me from having to go to settings. If that requires a separate approval that is OK.

But I would be happy with a tone1 and a vibrate when connected and a tone2 and vibrate when disconnected.

I figure I could probably do something with a timer and check for a wireless connection every few minutes but I was hoping that there might be an event I could just hook to all the time.

Thanks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Most of these things are not possible.

Running your app in the background in iOS is difficult. You can prevent the app from being killed by implementing the background location tracking feature (you will not be able to submit your app to the store).

You can periodically check the ip address with ServerSocket to find out if you are connected to a wifi network and show a notification when needed.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
There is a programm called " Internet Connection Notification ". It will inform you via alert tone or voice when your connection is up or down. You can also track how often you were connected during the day.
Thanks, but that is not what I am looking for. I only want to know if I am connected to a wireless connection or not.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
You can prevent the app from being killed by implementing the background location tracking feature (you will not be able to submit your app to the store).
I'm guessing you mean this:
https://www.b4x.com/android/forum/threads/background-location-tracking.50246/

my question - do I actually need to implement the service or is it enough just to add
B4X:
#PlistExtra: <key>UIBackgroundModes</key><array><string>location</string></array>
#PlistExtra:<key>NSLocationAlwaysUsageDescription</key><string>Track your location in the background for better ad revenue.</string>
#PlistExtra:<key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>
#PlistExtra:<key>NSLocationAlwaysAndWhenInUseUsageDescription</key><string>Track your location in the background for better ad revenue.</string>
to my project?
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
You will need to start the location service.
Sigh, is that going to suck up a lot of battery?
What if I set
B4X:
    StartBackground(locManager, 1000000) 'replaces locManager.Start
B4X:
does that help?
 
Upvote 0
Top