Apps made through .net maui don't work with local networks.
I'm using the .net 8 framework, and I followed the app to the ios system through .net Maui after connecting it to the computer through a data cable.
When I open the app, I get a request to access the local network and I agree to it. But still my app is not accessible.
I have asserted it correctly inside info.plist.
How can I fix this issue
Networking
RSS for tagExplore the networking protocols and technologies used by the device to connect to Wi-Fi networks, Bluetooth devices, and cellular data services.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
When using ssidPrefix in the descriptor and completing the AccessorySetupKit setup, I attempt to connect to the accessory's Wi-Fi hotspot using NEHotspotConfigurationManager joinAccessoryHotspot.
The connection fails with the following error:
Error Domain=NEHotspotConfigurationErrorDomain Code=1 "invalid SSID." UserInfo={NSLocalizedDescription=invalid SSID.}
I'm using a prefix that is at least 3 characters.
If I provide ssid instead of ssidPrefix it connects successfully.
Topic:
App & System Services
SubTopic:
Networking
Title: Loss of Internet Connectivity on iOS Device When Packet Tunnel Crashes
Feedback ticket: https://feedbackassistant.apple.com/feedback/14162605
Product: iPhone 12
Version: iOS - 17.5.1
Configuration: NETunnelProviderManager Configuration
Description: We are developing an iOS VPN client and have configured our packet tunnel provider according to Apple's guidelines. The configuration is as follows:
includeAllNetworks = YES
excludeLocalNetworks = NO
enforceRoutes = NO
This setup works as expected when the VPN successfully connects. However, we encounter a blocker issue where the device loses internet connectivity if the packet tunnel crashes.
Steps to Reproduce:
Configure the NETunnelProviderManager with the above settings.
Connect the VPN, which successfully establishes a connection.
Verify that resources are accessible and internet connectivity is functional.
Packet tunnel to crash unexpectedly.Observe that the NE process (Packet Tunnel) restarts automatically, as expected and attempts to reconnect the VPN;
however, the device now lacks internet connectivity, preventing VPN reconnection.
Try accessing resources using Safari or any other internet-dependent app, resulting in an error indicating the device is not connected to the internet.
Actual Results: The device loses internet connectivity after the packet tunnel crashes and fails to regain it automatically, preventing the VPN from reconnecting.
Expected Results: The device should maintain internet connectivity or recover connectivity to allow the VPN to reconnect successfully after the packet tunnel process restarts.
Workaround - iPhone device needs a restart to regain internet connectivity .
WiFi and Bluetooth are both enabled on Mac and iPhone, neither device is connected to a network
Running MultipeerConnectivity on the Mac as Advertiser and iPhone as Browser, the invitation is sent from the phone and accepted by the mac, but the connection is then dropped. This doesn’t happen when the Advertiser is another iOS device.
STEPS TO REPRODUCE THE PROBLEM
We have created a small sample project that demonstrates the problem. It can be found at: https://github.com/eidria/Multipeer-Progress-Demo.git. It contains both a Mac app and a iOS app.
Run the Mac app and start Advertising
Run iOS app and start Browsing
The iOS app automatically issues an invitation to the browser (Mac) which accepts. Shortly after the connection is dropped.
I am working on developing a client to complete 8021.x wireless authentication by python.
According to the CoreWLAN Documentation scanForNetworks(withName:), I'm going to use scanForNetworksWithName_error_ and associateToEnterpriseNetwork_identity_username_password_error_ provided in CoreWLAN. And I wrote a script to have a try.
import os
import pwd
from CoreWLAN import CWWiFiClient
from Foundation import NSString
def get_real_user():
sudo_user = os.environ.get('SUDO_USER')
if sudo_user:
return sudo_user
return os.environ.get('USER', 'root')
def run_as_user(username):
if os.geteuid() == 0:
uid = pwd.getpwnam(username).pw_uid
gid = pwd.getpwnam(username).pw_gid
os.setuid(uid)
def connect_to_enterprise_network(ssid, username, password):
try:
real_user = get_real_user()
if os.geteuid() == 0:
run_as_user(real_user)
client = CWWiFiClient.sharedWiFiClient()
interface = client.interface()
if not interface:
print("no interface")
return False
print("scaning...")
error = None
scan_result, error = interface.scanForNetworksWithName_error_(ssid, None)
if error:
print(f"scan fialed: {error.localizedDescription()}")
return False
target_network = None
for network in scan_result.allObjects():
if network.ssid() == ssid:
target_network = network
break
if not target_network:
print("no target network")
return False
success, error = interface.associateToEnterpriseNetwork_identity_username_password_error_(
target_network,
None,
NSString.stringWithString_(username),
NSString.stringWithString_(password),
None
)
if not success:
print(f"connect failed: {error.localizedDescription() if error else 'unknown error'}")
return False
print("connect successfully")
return True
except Exception as e:
print(f"exception: {str(e)}")
return False
if __name__ == "__main__":
ssid = "ssid"
username = "username"
password = "password"
success = connect_to_enterprise_network(ssid, username, password)
However, I can only execute this script normally under non-root permissions. When I switch to root and execute it, the variable "scan_result.allObjects()" will be an object without any ssid and bssid. Finally the function prints "no target network" and returned.
<CWNetwork: 0x107104080> [ssid=(null), bssid=(null), security=WPA2 Enterprise, rssi=-52, channel=<CWChannel: 0x11e8a1fd0> [channelNumber=44(5GHz), channelWidth={20MHz}], ibss=0]
Compared with the value without sudo:
[<CWNetwork: 0x144650580> [ssid=ssid, bssid=<redacted>, security=WPA2 Enterprise, rssi=-55, channel=<CWChannel: 0x1247040d0> [channelNumber=149(5GHz), channelWidth={20MHz}], ibss=0]]
My python code will be included in an app that must be executed as a root user, so this issue can't be ignored and waiting for your help. THANKS!
My app helps users connect to Wi-Fi networks, and I have requested the Access Wi-Fi information entitlement. This allows the app to retrieve the current Wi-Fi information to ensure the user’s connection is successful.
Now, we are trying to implement an App Clip that enables users to connect to a specific Wi-Fi network through a QR code scan or NFC in certain scenarios. In the App Clip, I’ve requested the Hotspot entitlement, which allows the app to use the hotspot manager to configure Wi-Fi networks. However, since I cannot access the current Wi-Fi information in the App Clip, I’m unable to confirm whether the connection was successful.
None of my app's functionalities make use of local network. However, on launching the app on an iPad running iOS 18.2.1, I see an iOS prompt asking for local network permission by the app with a null usage description.
I know since the app does not have Privacy string for local network, I see the null message.
But my app does not use of local network so I am confused why I see this alert.
DESCRIPTION OF PROBLEM
We have developed an app and server based on the WireGuard protocol. While we have successfully implemented device-wide VPN, we are now working on enabling per-app VPN functionality.
The per-app VPN payload is successfully delivered, and the designated app can read the configuration and establish a connection to the VPN server. However, we are experiencing extremely slow download data rates, measuring only in bytes.
Steps Taken:
Created an app-layer payload.
Configured NETestAppMapping in the app’s Info.plist, using the VPNUUID defined in the payload for the Chrome app.
Despite these configurations, data transfer remains significantly slow. We would appreciate any insights into potential causes or recommendations to resolve this performance issue.
Thank you for your assistance.
How can NEPacketTunnelProvider launch the companion application, or notify user to launch the application?
I have built an iOS VPN that uses credentials stored in the keychain, and it works as expected. Now I'm trying to add OAuth login support.
Everything works fine at first. I login from the companion application, store tokens in the keychain, then launch the VPN from either System Settings or the companion application.
However, when the OAuth refresh tokens expire, or the OAuth IdP otherwise requires login, I can't perform the OAuth login from the NEPacketTunnelProvider. Login must happen from the companion application, which likely isn't running. I need the NEPacketTunnelProvider to either launch the companion application directly or to notify the user to do so.
Searching and reading docs yields:
You can't perform OAuth login from within the NEPacketTunnelProvider because it requires user interaction
There is no way to guarantee that the companion application is running on iOS (otherwise one would use NEVPNStatusDidChange)
You can't launch the companion application from NEPacketTunnelProvider using a custom URL because of security concerns
You might be able to launch the companion application from a system extension...
Some sources say you still can't guarantee that the system extension is loaded whenever the NEPacketTunnelProvider needs it anyway.
Of course, any of these conclusions could be wrong.
At this point I'm not sure where to begin. Is there another approach that could be initiated by the NEPacketTunnelProvider (push notifications, system notifications, smoke signals)?
Any help would be appreciated.
Thanks,
Bill Welch
Topic:
App & System Services
SubTopic:
Networking
Tags:
Extensions
Network Extension
User Notifications
My app sent a network request to the backend. The backend returns a 200, but the front end received a -1001 or -1005 NSURLError. Any clue why this could be happening?
I have an idea for a game where the Apple TV app acts as the host and discovers nearby iOS apps that can join the game. Each iOS app needs to be able to have the user draw, tap, etc and have all the events be delivered in real time to the Apple TV where the effects will be rendered immediately (imagine a co-op game played in your lounge room where guests user their own devices to control aspects of the UI on the shared Apple TV screen)
MPC is discontinued and DeviceDiscoveryUI is limited to only a single iOS device so I’m trying to figure out the best way to do the P2P networking.
Reading/watching videos suggests that using GKMatchMaker and friends seems like it might suffer from latency problems (because everything has to go via Game Centre - or does it?) plus I’m not sure how I’d deal with the fact that the owner of the Apple TV is likely to signed into the same game centre id on both the Apple TV and their own devices to which would mean they wouldnt be able to play because the host can’t invite “themselves” on another device (or can it?)
Soooo… I’m looking for suggestions on how best to move forward. I’ve read https://developer.apple.com/documentation/technotes/tn3151-choosing-the-right-networking-api which is very useful but there’s no clear suggestion that would work.
Using the Network for the real time messaging seems doable but dealing with discovery / invites seems like a massive pain that I’d prefer to use built-in libraries if possible.
Any suggestions would be gladly received. Thanks a lot
Topic:
App & System Services
SubTopic:
Networking
Tags:
GameKit
Nearby Interaction
Multipeer Connectivity
Hi there, I'm having an issue hoping someone could help. We have an iOS app that uses CoreBluetooth to connect to peripherals using the central manager. The app works great - However, when using the same exact central manager for our watchos app, it will attempt to connect, but I never get a callback for either didConnect or didFailToConnect.
The watch can connect successfully to other BLE devices, so the watch itself is capable of BLE connectivity.
Here's a list of thing's I've tried (unsuccessfully):
1) Added every bluetooth-related entitlement to info.plist
Privacy - Bluetooth Always Usage Description
Privacy - Bluetooth Peripheral Usage Description
Background Modes: App communicates using CoreBluetooth, App shares data using CoreBluetooth
2) Checked for Single-Connection Limits
Verified that the iPhone was fully disconnected from the peripheral to ensure the device wasn’t limited to one connection.
Attempted to connect on watchOS alone (with iPhone turned off)
3) Tried various options for CBCentralManager, scanForPeripherals, and connect
I went through all the keys for various options and tried just setting them, they had no effect
CBCentralManagerOptionShowPowerAlertKey, CBConnectPeripheralOptionEnableTransportBridgingKey
Item 2
4) Tried .registerForConnectionEvents()
5) Set peripheral's delegate to the central in the didDiscover, stored it in a variable to ensure a strong reference to it
I get no warnings either. The last time I ran into something like this, I found out the watchOS blocks TCP sockets. If I print out the CBPeripheralState a few seconds after trying to connect, it shows its stuck on CBPeripheralStateConnecting.
Any advice or direction is greatly appreciated
Below is the code and various print outs (day 2 into debugging, so it's not pretty)
class WatchBLEManager:NSObject,CBCentralManagerDelegate, ObservableObject{
var centralManager: CBCentralManager?
@Published var devices : [String:AtomBLEDevice] = [:]
private var scanningDevice:AtomBLEDevice?
var bleStatus:WatchBLEStatus = .blePoweredOff
func startBLE() {
centralManager = CBCentralManager(delegate: self, queue: nil,options: [CBCentralManagerOptionShowPowerAlertKey: true])
self.centralManager?.delegate = self
}
func startScan() {
self.centralManager?.scanForPeripherals(withServices: [],options: [CBCentralManagerScanOptionAllowDuplicatesKey : true])
self.centralManager?.delegate = self
}
func stopScan() {
print("stopping scan")
self.centralManager?.stopScan()
filterName = ""
scanningDevice = nil
}
func centralManagerDidUpdateState(_ central: CBCentralManager) {
switch (central.state) {
//... other states omitted
case .poweredOff:
bleStatus = .blePoweredOff
// bleStateDelegate?.didBlePoweredOff()
for device in devices.values{
device.isConnected = false
}
print("BLE is Powered Off")
case .poweredOn:
bleStatus = .blePoweredOn
// bleStateDelegate?.didBlePoweredOn()
startScan()
centralManager?.registerForConnectionEvents()
print("Central supports extended scan and connect: ", CBCentralManager.supports(.extendedScanAndConnect))
print("powered on")
@unknown default:
print("BLE is Unknown")
}
}
private let connectionQueue = DispatchQueue(label: "com.atom.connectionQueue")
var connectingTo: String? = nil
var peripheral: CBPeripheral? = nil
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
guard let localName = advertisementData[CBAdvertisementDataLocalNameKey] as? String else { return}
if localName.contains("Atom") {
print("\nConnecting to \(localName)")
print("\tAdvertising data: \(advertisementData)")
print("\tANCS Authorized: ",peripheral.ancsAuthorized)
print("\tServices", peripheral.services, "\n")
self.peripheral = peripheral
self.peripheral?.delegate = self
// central.registerForConnectionEvents()
// central.delegate = self
peripheral.delegate = self
DispatchQueue.main.async {
// central.connect(peripheral)
self.centralManager?.connect(peripheral, options: [ CBConnectPeripheralOptionEnableTransportBridgingKey: true])
}
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) {
print("\tState", String(describing: peripheral.state))
print("Connected Peripherals: \(self.centralManager?.retrieveConnectedPeripherals(withServices: []))")
}
}
}
// Never gets called for watchos
func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
print("Connected to peripheral: \(peripheral.identifier)")
if let atomDevice = getAtomBLEDevice(peripheral: peripheral) {
//atomDevice.setPeripheral(perpipheral: <#T##CBPeripheral?#>)
atomDevice.isConnected = true
atomDevice.isConnecting = false
//delegate?.didConnected(atomBLE: atomDevice!)
atomDevice.startDiscoveringService()
//atomDevice?.delegate?.didConnected(atomBLE: atomDevice!)
print("Connected: \(peripheral.name)")
} else {
print("no matching atom device found for didConnect")
print("connected peripheral :",peripheral.identifier.uuidString)
}
}
func centralManager(_ central: CBCentralManager, connectionEventDidOccur event: CBConnectionEvent, for peripheral: CBPeripheral) {
print("Connection event: \(event)")
}
func centralManager(_ central: CBCentralManager, didFailToConnect peripheral: CBPeripheral, error: (any Error)?) {
print("Failed to connect: \(error?.localizedDescription)")
}
func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) {
let atomDevice = getAtomBLEDevice(peripheral: peripheral)
atomDevice?.isConnected = false
print("Peripheral disconnected:\(peripheral.name)")
}
func clearData() {
filterName = ""
for device in devices.values{
disconnect(atomBLEDevice: device)
device.perpipheral?.delegate = nil
}
devices = [:]
scanningDevice = nil
// delegate = nil
centralManager = nil
}
}
extension WatchBLEManager: CBPeripheralDelegate {
}```
I have an app that is communicating with a non-HTTP server over TCP/IP. Most everything is working, but I was testing some error conditions and the first one I tried was turning the server off and then trying to send it a message.
I'm using code that uses NWConnection and involves an async method that includes a withCheckedContinuation. Inside this code are checks for errors in the closures, etc. You've seen the example code posted here in the forums. But none of the error code ever gets invoked. I also have a state handler to check the state of the TCP connection.
What I see when I send the request is:
connection goes to .preparing state
nothing happens for about 45 seconds
I then get two errors:
inline-code
nw_endpoint_flow_failed_with_error [C4.1.1 192.168.86.44:3040 in_progress channel-flow (satisfied (Path is satisfied), viable, interface: en0[802.11], ipv4, dns, uses wifi)] already failing, returning
inline-code
nw_endpoint_flow_failed_with_error [C4.1.1 192.168.86.44:3040 cancelled channel-flow ((null))] already failing, returning
then the connection state goes to .waiting
and nothing else happens. I would really like to capture the errors I see in the Xcode console, but I don't know how to catch them. Anyone have any ideas? Is there a better way to send the first message (or a ping or whatever) to a non-HTTP server and see if it is there?
Thanks,
Robert
Topic:
App & System Services
SubTopic:
Networking
When I make a local network HTTP request, an error occurs. I'm sure I've granted wireless data permissions and local network permissions, and I'm connected to the correct Wi-Fi. This problem is intermittent, but once it happens, it will keep happening, and the only way to fix it is to restart the phone. Here is the error log:
sessionTaskFailed(error: Error Domain=NSURLErrorDomain Code=-1009 "似乎已断开与互联网的连接。" UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x30398a5b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorNWPathKey=unsatisfied (Local network prohibited), interface: en0[802.11], uses wifi, _kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<63>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask .<63>"
), NSLocalizedDescription=似乎已断开与互联网的连接。, NSErrorFailingURLStringKey=http://192.168.2.1:80/v1/parameters, NSErrorFailingURLKey=http://192.168.2.1:80/v1/parameters, _kCFStreamErrorDomainKey=1})
I am developing an App for iOS/iPhone that communicates with an external hardware.
The external hardware is a hotspot to which the iPhone connects and every 10 seconds this hardware sends data to the iPhone by opening a TCP connection on the local network to the indicated port.
On the iPhone side I use NWListener to retrieve the connections. When a connection is opened, I retrieve the data sent by the hardware and I close the connection.
Because I also need to have the exact position of the user I have activated the Location background mode using the CoreLocation framework.
If I put my application in the background everything works correctly. I retrieve the data every 10s as well as the changes in the user's positions.
After 15 minutes however, and it is very precise, the server (NWListener) no longer accepts connections as if there was a timeout or a limitation to having a server running in the background in an iOS application.
Can you help me?
Thanks
Topic:
App & System Services
SubTopic:
Networking
I am working on watch os project. I need to check network connectivity when user turn on and off the network.
I am using NWPathMonitor for check network availability. I am connected with wifi but it still showing unsatisfied not real device but it's working perfect on simulator.
I am learning about layer 3 VPN implementations for MacOS, and am slowly making my way through docs and tutorials. I noticed that part of creating an instance of NETunnelProviderManager on the app side of the project requires the specification of protocolConfiguration via an instance of NETunnelProviderProtocol. One of the arguments for this class is serverAdress, which to my understanding, tells the OS where to route traffic towards at the end of the day.
My question: many VPNs these days allow the option to specify the location for which you want your traffic to be routed through. I imagine this would necessitate changing this serverAddress field in the backend. However, setting this option (on a commercially available VPN) doesn't typically prompt the OS notification that you get when initially installing a VPN configuration for the first time. How is this functionality achieved? I could see one possible solution being that most VPN providers route through a main service beforehand (so the first IP in the chain never has to change), though I could see this being problematic for a number of other reasons.
Assuming you have a valid NETunnelProviderManager object called manager, is this valid?
self.manager?.protocolConfiguration?.serverAddress = "somewhereElse"
Even if it compiles, will the traffic be properly re-routed?
My understanding of the flow right now is that in order to "lock in" a new configuration, or modify it, you need to call manager.saveToPreferences, which triggers the OS notification I mentioned earlier.
I'm looking at implementing an iOS app that has includes a Content Filter Provider to block access to certain domains when accessed on the device.
This uses NEFilterManager, NEFilterDataProvider and NEFilterControlProvider to handle configuration and manage the network flows and block as necessary.
My question is can you deploy this in an iOS 18+ app on the App Store to devices which are unmanaged, unsupervised and don't use Screen Time APIs?
Although not 100% clear, this technote seems to say it is not possible:
https://developer.apple.com/documentation/Technotes/tn3134-network-extension-provider-deployment
Testing this on a Developer device and build works successfully without any MDM profiles installed.
A similar approach using the same APIs also works on macOS once user permissions have been given.
If it can't work on unsupervised, unmanaged iOS devices, is possible for the user to first manually install a MDM profile which includes the required 'Content Filter' details and then have it work?
If not, how would you filter iOS network traffic on an unmanaged, unsupervised device?
Is it necessary to use a VPN or DNS approach instead (which may be a lot less privacy compliant)?
in the local testing, if the binary data length is small like 300 bytes, then it can send binary data success, but if the data length is more that 3000 bytes, then it will failed and print the error like in the screen capture
Topic:
App & System Services
SubTopic:
Networking
Hi, I've noticed a weird behavior happening on Sequoia with DF bit:
On machine where SIP is disabled, when I do /sbin/ping -D -s 1400 8.8.8.8 I do see the DF bit in wireshark
On machine where SIP is enabled, when I do /sbin/ping -D -s 1400 8.8.8.8 I do not see the DF bit in wireshark
The -D flag should set the DF bit but for some reason it doesn’t if the SIP is enabled.
Perhaps there was any change in permission/entitlements mechanism in Sequoia that can explain it ? I'm using the built-in ping command so maybe it should be signed with more entitlements ?