I am currently upgrading our app from Captive Network Framework to Network Extenstions Framework(i.e. NEHotspotHelper).
So, I come to the following in our code:
[myReq bindToCommand:cmdRef];Where myReq is an NSMutableURLRequest and cmdRef is a CNPluginCommandRef. The bindToCommand is documented in the CaptiveNetowrkPlugin Handbook (page 12) as:
Making Network Connections
Any network connection that the CNPlugin opens to authenticate to the network
MUST be bound to the supplied command. This ensures that the network traffic
goes over the authenticating interface and not the default interface that the system
might choose automatically.
When using NSMutableURLRequest, use the following objective C method:
@interface NSMutableURLRequest (CaptiveNetworkPlugin)
- (void)bindToCommand:(CNPluginCommandRef)cmd;In other words, we bind the CNP command to the NSMutableURLRequest then perform our usual setup and (my guess is) that NSMutableURLRequest handles the rest under the covers. (If I misunderstand, please clarify:)
As far as I can tell, the closest method to bindToCommand translates to NEHotspotHelperCommand createTCPConnection:
Create a new TCP connection over the network associated with the command.
- (NWTCPConnection * _Nonnull)createTCPConnection:(NWEndpoint * _Nonnull)endpoint
But, I’m not quite sure how to use it. The SimpleTunnel sample code doesn’t use the NEHotspotHelper version of the call.
Anyone have any sample code or suggestions on how to use createTCPConnection in NEHotspotHelper?
~Gene