What actual method calls, excluding Bonjour, triggers the "would like to find and connect to devices on your local network" permission notification on iOS 14?
This is the screen shot from the WWDC session on this new permission. Which is only somewhat helpful as an overview. I'm more interested in figuring out what all method calls trigger this.
If you're using react native with a debug configuration, then you are including all the code responsible for communicating with your dev machine so you can probably ignore this message.
However it's best to check you have no other libs that require access too. To do this just build a Release version and see if the message persists.
In a nutshell, Bonjour. Its use is no longer "transparent". See https://developer.apple.com/videos/play/wwdc2020/10110/ for more information:
If your app interacts with devices using Bonjour or other local networking protocols, you must add support for local network privacy permissions in iOS 14.
Even an existing app is subject to this rule; the first attempt to use Bonjour triggers the authorization alert.
Apple (Eskimo on the Dev Forums) released a FAQ providing more details around this alert:
https://developer.apple.com/forums/thread/663858
Particularly, providing more info as to what triggers this alert is FAQ-2:
https://developer.apple.com/forums/thread/663874
What operations require local network access?
The general rule is that outgoing traffic to a local network address
requires that the user grant your app local network access. Common
scenarios include:
Making an outgoing TCP connection — yes
Listening for and accepting incoming TCP connections — no
Sending a UDP unicast — yes
Sending a UDP multicast — yes
Sending a UDP broadcast — yes
Receiving an incoming UDP unicast — no
Receiving an incoming UDP multicast — yes
Receiving an incoming UDP broadcast — yes
These TCP and UDP checks are done at the lowest levels of the system
and thus apply to all networking APIs. This includes Network
framework, BSD Sockets, NSStream, NSURLSession and WKWebView, and any
other protocols that you layer on top of those.
IMPORTANT Receiving an incoming UDP multicast or broadcast does not
currently require local network access but, because we hope to change
that in a future update, our advice right now is that you write your
code as if did (r. 69792887, 70017649).
Resolving link-local DNS names (those ending with local, per RFC 6762)
requires local network access. Again, this check applies to a wide
variety of APIs including <dns_sd.h>, <net_db.h>, Network framework,
NSStream, and NSURLSession.
Finally, all Bonjour operations require local network access:
Registering a service with Bonjour — yes
Browsing for Bonjour services — yes
Resolving a Bonjour service — yes
Again, these checks apply to all APIs that use Bonjour, including
<dns_sd.h>, Network framework, NSNetService, and Multipeer
Connectivity.
Note You must declare the Bonjour service types you use in your
Info.plist. See How do I map my Multipeer Connectivity service type to
an entry in the Bonjour services property? for details.
Bonjour-based services where you don’t see any details of the network
do not require local network access. These include:
AirPlay — no
Printing via UIKit — no
One of my apps was triggering this prompt unexpectedly in our internet multiplayer mode. We use RakNet for our networking (which is a C++ lib that uses BSD sockets to send/receive UDP) and I was able to track the problem to the RNS2_Berkley::BindShared function here.
After creating a UDP socket, RakNet tests health/validity of the socket by having it send a little test packet to itself. iOS 14 was flagging this send-to-self behaviour as communication on the local network. I'm not sure if this send-to-self behaviour is a common pattern in socket programming, or a particular quirk of RakNet. Frustratingly, the OS prompt didn't actually appear until later when the socket was used for real which made the issue very hard to track.
I think that this is a false-positive from the OS and raised it with Apple (FB8802121). I won't be holding my breath though so I've just disabled that RakNet behaviour for iOS and am hoping that it wasn't too important.
Edit: To more directly answer the original question: sendto is a method call that can trigger this prompt.
I get rejected from apple app review for this alert. I'm using GCDWebServer which creates an embedded http server in my app.
I think I should provide a message in info.plist to tell user what my app want to do. Before I didn't set the text string in it.
And I would like to update if this will pass the app review.
<key>NSLocalNetworkUsageDescription</key>
<string>xxx uses the local network to connect with devices around you.</string>
Regarding iOS 14: permission request: would like to find and connect to devices on your local network and after numerous deploys to my physical device, I have figured out what causes this in my case.
I have a Xamarin.Forms app which
calls localhost:xxxx to do some local logging while I develop
I use a product thats called LiveSharp that does local hot reloading for XAML AND C# code changes.
So Livesharp actually communicates with a server on my localhost as well.
After disabling both of these and a fresh clean install on my physical device, the permission request has GONE .. Yay
Note: I had to completely remove LiveSharp nuget packages from my project.
Also I tried to re-enable my localhost logging, and for some reason the permission request does not appear.. :headscratch
So: remove any localhost communication that happens in your app. Or at least put an if statement around it allowing it if set to true in appsettings
I also have a Xamarin app and I used the package LiveXaml. After removing it the message was gone.
I would like to use an iOS device as a gateway between BLE device and cloud when app is in background. Is this (a) possible and (b) according to Apple's guidelines?
Architecture:
BLE device <-> iOS <-> Cloud
The scenario is as follows:
cloud sends message to BLE device
BLE device sends response (result) to cloud
solution for step 1:
As far as I understand 'background notifications' [1] can be used to trigger an action on the iOS device when app is in background. Is one allowed to send a message to BLE device in this context?
Is there a more generic solution, that works for android and iOS?
solution for step 2:
iOS 'Core Bluetooth' allows background processing [2]. So once the result is available the iOS app would be triggered again. In this context, is it allowed to open a connection to cloud (RESTful API, Azure Service Bus, Azure IoT Hub, or similar) to forward the result?
[1] https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app
[2] https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
Yes! it is possible, i created an article that shows how to make an iPhone gateway and connect to another board (ESP32) using BLE.
What i did was i first connected to Google Cloud IoT Core using MQTT,once the iPhone was connected i scanned for the board using Core Bluetooth. Then it would connect to the ESP32, the ESP32 would send the data to the iPhone and the iPhone would publish this data to PubSub.
Controlling Your Phone From The Cloud
Yes, It is possible.
I am agree with your 2nd solutions.
bluetooth-central—The app communicates with Bluetooth low energy peripherals using the Core Bluetooth framework.
bluetooth-peripheral—The app shares data using the Core Bluetooth framework.
I know that I can keep a socket alive in the background for VOIP applications with kCFStreamNetworkServiceTypeVoIP. However this is deprecated on iOS 9 and they recommend to use the PushKit Framework for VOIP purposes.
My problem is that my App is suppose to work without internet connectivity so I have no way of using remote notifications. The App connects to a SIP device for VOIP calling purposes.
Any suggestions would be helpful for a future proof solution.
Thank you
By the way, when building with the iOS 10+ SDK, this feature has been removed entirely. See QA1938. Apple does mention that some applications like yours don't have access to the Internet, but then says the only way to do it is for you to open certain ports to the APNS servers, which still requires some Internet, so it doesn't really answer your question.
Some VoIP apps are specifically designed to work in special networks,
ones that don’t provide access to the wider Internet. To use PushKit
in such an environment you must configure the network to allow iOS
devices to access the Apple Push Notification Service. See TCP and UDP
ports used by Apple software products for information on how to do
this.
I have a http://redbearlab.com/bleshield/.
I successfully tested the Chat example and i have sent a message from iPhone to Arduino.
Now i want to test the ANCS functionality. From what i heard, the iPhone must be the Peripheral and BLE Shield must connect to ANCS service and then it will receive notifications.
Is it possible to discover and connect to bluetooth devices using BLE Shield? How?
Thank you!
Is it possible to discover and connect to bluetooth devices using BLE Shield?
yes it is possible! I'm currently writing an article and I'm also about to publish a library that handles ANCS notifications. It's way more complicated than only running the Chat example, though.
How?
To access the ANCS, here are the key things to do:
open nRFGoStudio
add the ANCS services into the pipe definition
force bonding to access the services
and generate the new services.h
in your code
when bonding is done shutdown and restart the BLE radio
wait until the ANCS pipes are opened
when they all are opened, subscribe to the ANCS Notification Source
to get more details, and a working library, please have a look at the following article I wrote:
http://i.got.nothing.to/code/on/avr-for-ble-and-ios
and the library:
https://github.com/guyzmo/avr_nrf_ancs_library
HTH
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.