-1

I'd like to do a simple location aware application that minimizes impact on battery life. In my case, it would actually be quite sufficient just to know that I've joined a particular wifi network.

Does anyone know of a way to get a background notification whenever my device joins a wifi network?

Mike Cargal
  • 6,610
  • 3
  • 21
  • 27

3 Answers3

1

You can use Reachability to check you device is connected with wifi or not. Check the code here

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
  • I looked at reachability, but did not see anything for notifications. I suppose I could just periodically wake up and check, but, given that ios just joins the network when it sees it, I was hoping I could get a notification to wake my app only when that happened. – Mike Cargal Sep 12 '13 at 16:56
  • @MikeCargal it will call the method when wifi is detected or when its disconnected. Download the code from here check here: https://developer.apple.com/library/ios/samplecode/Reachability/Reachability.zip and check it. – Nirmalsinh Rathod Sep 12 '13 at 18:52
0

(comment) Do you mean when your device automatically connects to a wifi network?

  • yes (preferably, just tell me when I connect to a network I identify, but I could easily settle for a notification on connection to any wifi network, as long as I can determine which network I just connected to.) – Mike Cargal Sep 12 '13 at 12:26
0

I think you should use CoreWLAN framework to get info about that https://developer.apple.com/library/mac/documentation/Networking/Reference/CoreWLANFrameworkRef/_index.html

slysid
  • 5,236
  • 7
  • 36
  • 59
  • I just looked through that framework (admittedly, briefly) but did not see any sort of notification capability. – Mike Cargal Sep 12 '13 at 12:25
  • Check this out if it helps you http://stackoverflow.com/questions/15047338/is-there-a-nsnotificationcenter-notification-for-wifi-network-changes – slysid Sep 12 '13 at 13:04
  • It looks like this reference is what I'm looking for. The reachabilty stuff seems more oriented to whether or not a particular endpoint is "reachable" (and if, so, by what means). I want to be able to detect when my device has joined a specific network, and it appears that this article and answers will get me going in the right direction. It's the System Configuration piece that I was missing. – Mike Cargal Sep 15 '13 at 11:32