Is there a way to programmatically subscribe to WiFi notifications on iOS?
For example, assuming the user has not disabled WiFi notifications, when they are within range of a WiFi network, the operating system provides a notification of available networks. Can an app subscribe to this notification and provide it's own notification to the user?
Could the app could even check the SSID to see if it is a specific network, and then perform some action?
Have a look at the Reachability demo and the System Configuration classes.
This SO question covers this ground and the SSID's: IOS notification of wifi connection including SSID
It looks like the Captive Network Support might also be useful, ito finding the names of networks to which the user is not connected.
Related
I'm are working on a project that's required to be in a fully isolated VPN network.
I'd like to find if there's any special entitlement for iOS apps that provide sending and receiving push notifications without using APNs servers.
I found a topic under Network Extension in Apple documentation "Local Push Connectivity" but it requires the iOS device to be using a specific SSID that requires WiFi to work as mentioned in Apple documentation:
"When a user’s iOS device joins a Wi-Fi network that has an SSID matching a configured SSID in your NEAppPushManager instance, the system launches your app extension and instantiates the NEAppPushProvider subclass within that app extension."
Source:
https://developer.apple.com/documentation/networkextension/local_push_connectivity
I also found a sample code from Apple's documentation, "Receiving Voice and Text Communications on a Local Network"
But the sample mentioned that it "Provide voice and text communication on a local network isolated from Apple Push Notification service by adopting Local Push Connectivity."
Source:
https://developer.apple.com/documentation/networkextension/local_push_connectivity/receiving_voice_and_text_communications_on_a_local_network
is there a way to receive Push Notifications & VoIP Notifications in a local and isolated network using VPN and cellular data only ?
iOS 15 has added the ability to watch for specific LTE networks as well as specific WiFi SSIDs to enable the NEAppPushProvider. See the matchPrivateLTENetworks property on NEAppPushManager -- as of this writing the documentation for it is very sparse, but the sample code you linked to has been updated to support private LTE networks.
I noticed by in Boingo's Wi-Finder iOS app, that the app pushes a notification to the user once he reaches an access point regestered at Boingo's database. The notification tells the user that he can access the wifi network.
How is that done iOS?
I think it can be done by observing the device's connectivity with Reachability class in AppDelegate 's didFinishLaunchingWithOptions
and when networkStatus is equals to ReachableViaWiFi then call application.registerForRemoteNotifications()
Update :
there are 2 types of notifications : Remote and Local
you can configure your app to send local notification but you need to set it contents before,
here you can find Apple's guide on how to handle local notification
You can make use of CLLocationManager and UserNotifications to achieve this.
You can use the region-monitoring services like CLCircularRegion class (to get geographical regions) or CLBeaconRegion class (to get beacon regions) to get notified when the user crosses a region-based boundary. If the boundary crossing occurs even if your app isn't running, the system automatically wakes it up (or relaunches it) in the background so that it can process the event.
In this case, the options dictionary passed to the application(_:didFinishLaunchingWithOptions:) method of your app delegate contains UIApplicationLaunchOptionsKey.location. Then trigger a local notification in order to notify the user the available services in that location.
Examples:-
Using location monitoring:- https://www.raywenderlich.com/136165/core-location-geofencing-tutorial
Using iBeacons - https://www.raywenderlich.com/101891/ibeacons-tutorial-ios-swift
NB. As suggested in other answers Reachability class also we can use. But Reachability cannot be used if the app is in background or terminated. To trigger reachability when app is in background we can follow this: https://stackoverflow.com/a/35615381/4637057. But unfortunately, the disadvantage here is, the more often the Background Fetch is set to work to an app, the more resources will be used. iOS protects itself and the device by applying limitations to the apps that try to use the API very often, so be cautious when setting custom time intervals. Also Background Fetch will cause a battery drain very quickly.
Also only if the app get connected to that wifi network, Reachability can trigger notification. But Boingo will notify the user even if the app is in background and phone is not yet connected to the wifi. So I strongly suspect they are using location services to detect whether user entered an area where wifi is available.
You can get the SSID of the Wifi hotspot and if it's registered one, you can follow Mohy's answers.
Please check the following link.
How to get Wifi SSID in iOS9 after CaptiveNetwork is deprecated and calls for Wifi name are already blocked
This will help you to get the SSID of Wifi hotspot.
Is it possible to simultaneously broadcast my iOS app as an iBeacon and at the same time publish a service?
My app currently advertises a service, which works perfectly fine. My client app (central) is able to find the peripheral, connect, obtain the service and read data from the characteristic. However, if I update my server app (peripheral) to start broadcasting as an iBeacon emitter in addition to the service, I am no longer able to find services that I setup to advertise on the client app (central).
The idea of this is that I want to be able to read information from the server (peripheral) app when in close proximity from the client (central).
Is this technically feasible?
I was thinking about turning off iBeacon transmission when a device comes into close proximity and then starting the service broadcast, but there is no API in Core Bluetooth that calls back to the emitter when a client device enters the region being advertised.
Is this doable? Is there a workaround that would achieve something along these lines? I would like to avoid any networking, as this should be an offline solution.
Taz, For sure you can be an iBeacon and you can look for iBeacons. What I did and what I see other doing is combining iBeacons with other services, such as the CloudKit [which yes, means networking too] to add functionality to their basic functionality.
That said I can imagine an app in which your iBeacons switch to a different protocol when they see each other, the challenge; how-to negotiate a channel/UUIDs for a BLE peripheral/central pair.
I am still in the process of building, but have implemented something similar over the past months... in short you hardcode an initial channel to start your BLE conversation, your first and only exchange on said channel being to agree a new BLE one to use.
Assume a device was offline with no service neither WiFi to begin with, is there a callback/delegate to tell that the device is back to be connected once the service or WiFi is available? or do we have to proactively pull the status?
You could check it with the Rechability class:
The Reachability sample application demonstrates how to use the SystemConfiguration framework to monitor the network state of an iPhone or iPod touch. In particular, it demonstrates how to know when IP can be routed and when traffic will be routed through a Wireless Wide Area Network (WWAN) interface such as EDGE or 3G.
here is an Example
G'day Guys,
I've been using the reachability API with reachability status callbacks to determine whether an application is connected over 3G or wifi. It's an application that acts as a voice extension for an existing piece of hardware and as such we're using the VoIP APIs to run in the background and accept calls etc.
Is there a definitive way other than using reachability status callbacks to determine whether you can access a particular IP endpoint or not? I could use an ASIHTTPRequest and then check if it timed out but that may cause potential problems for me in the long run.
I'm not looking for a programmatical answer but more any insights other developers would have on how to manage a roaming between the two in the background if you have a persistent connection. Basically if the device roams over to 3G I need to destroy the session on the device and if it roams back over to Wifi I need to recreate the session.
Any feedback or advice would be welcome.
The Reachability APIs will provide the connection change notifications to your app so that you can know when the connectivity changed from WWAN to wifi. It will not tell you if you've changed from Edge to 3G or LTE unfortunately. The Reachability API also has methods to test reachability to a specific host. So, in your app you can listen for the notifications that the connection method has changed, then when it does change test reachability to your target host and at that time make the decision whether to rebuild the session or leave it intact.