here my code to using multicast : guard let multicast = try? NWMulticastGroup(for: [ .hostPort(host: "224.0.0.251", port: 5353) ]) else { return }
self.group = NWConnectionGroup(with: multicast, using: .udp) group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { (message, content, isComplete) in print("Received message from (String(describing: message.remoteEndpoint))")
let sendContent = Data("ack".utf8) message.reply(content: sendContent) } group.stateUpdateHandler = { (newState) in print("Group entered state (String(describing: newState))") } group.start(queue: .main)
i have try every library for socket and every time get error on real ios device ios 14 and 15
when start happen stateDidUpdate called with field : 2021-11-01 11:07:21.106160+0200 SamRiskSDKPOC[1528:39332] [connection_group] nw_connection_group_handle_listener_state_change [G1] listener failed with error Group entered state waiting(POSIXErrorCode: Network is down) Group entered state failed(POSIXErrorCode: Address already in use)
iv request for using multicast network from apple , get approved add the capability:
iv created .entitlement file and add to app setting
after i create developer provision profile and download it and run those:
➜ ~ codesign -d --entitlements :- /Users/menny-a/Library/Developer/Xcode/DerivedData/SamRiskSDKPOC-gccczhfgcyqowifmuucaawrwfibu/Build/Products/Debug-iphoneos/SamRiskSDKPOC.app | grep -A 1 "com.apple.developer.networking.multicast" Executable=/Users/menny-a/Library/Developer/Xcode/DerivedData/SamRiskSDKPOC-gccczhfgcyqowifmuucaawrwfibu/Build/Products/Debug-iphoneos/SamRiskSDKPOC.app/SamRiskSDKPOC com.apple.developer.networking.multicast ➜ ~ security cms -D -i /Users/menny-a/Library/Developer/Xcode/DerivedData/SamRiskSDKPOC-gccczhfgcyqowifmuucaawrwfibu/Build/Products/Debug-iphoneos/SamRiskSDKPOC.app/embedded.mobileprovision | grep -A 1 "com.apple.developer.networking.multicast" com.apple.developer.networking.multicast after i done this my plist change :
on ios simulatore work perfect on read ios device not please help