<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Paresh Vaghela on Medium]]></title>
        <description><![CDATA[Stories by Paresh Vaghela on Medium]]></description>
        <link>https://medium.com/@prvaghela?source=rss-b2de3a5c7789------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6QVpCcVuIqbHvKO5qVlCdA@2x.jpeg</url>
            <title>Stories by Paresh Vaghela on Medium</title>
            <link>https://medium.com/@prvaghela?source=rss-b2de3a5c7789------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 07:11:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prvaghela/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NEHotspotHelper — Register an app as a Hotspot Helper]]></title>
            <link>https://medium.com/@prvaghela/nehotspothelper-register-an-app-as-a-hotspot-helper-cf92a6ed7b72?source=rss-b2de3a5c7789------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf92a6ed7b72</guid>
            <category><![CDATA[wifi]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[hotspots]]></category>
            <dc:creator><![CDATA[Paresh Vaghela]]></dc:creator>
            <pubDate>Tue, 26 Sep 2017 12:15:24 GMT</pubDate>
            <atom:updated>2017-09-26T12:15:24.067Z</atom:updated>
            <content:encoded><![CDATA[<p>The NEHotspotHelper interface allows an app to participate in the process of joining Wi-Fi/hotspot networks. The <a href="https://developer.apple.com/reference/networkextension">documentation from Apple</a> is sordid to say the least. Here are a few bits and pieces of information that will help you understand the API better.</p><h3>Apply for the Network Extension Entitlement</h3><p>You may already know this but to use the NEHotspotHelper API you will need to <a href="https://developer.apple.com/contact/network-extension">apply</a> for the Network Extension Entitlement from Apple. It may take several days for Apple to approve or reject your application.</p><h3>Modify your Provisioning Profiles</h3><p>Once you are granted the entitlement, go to iOS developer console and add the entitlement to your developer and deployment provisioning profiles. Many on the Internet will tell you to create a new set of provisioning profiles. That is not necessary. You can add entitlements to existing profiles. Download these modified profiles and re-install them on your development machine.</p><h3>Add Background Mode</h3><p>In our case we wanted to use the Wi-Fi Hotspot Authentication API of NEHotspotHelper. This requires the app to run in the background mode. Edit your Info.plist file and add the <strong>network-authentication</strong> background mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GwnGvIAsexGf3tApOvx3nQ.png" /><figcaption>plist file</figcaption></figure><h3>Use the Wi-Fi Hotspot Authentication API</h3><p>The purpose of the authentication API is to implement custom application level logic to authenticate the connection to a WIFI hotspot. This authentication is a two step process:</p><ol><li>First connect to the hotspot providing the hotspot’s password.</li><li>Then perform custom authentication. For example, this can involve communicating with a server and passing additional credentials.</li></ol><p>This process uses a callback based approach. The first thing you do is register a closure or lambda that is invoked at various times with a command object.</p><pre>let options: [String: NSObject] = [kNEHotspotHelperOptionDisplayName : &quot;Join our WIFI&quot; as NSObject]<br>let queue: DispatchQueue = DispatchQueue(label: &quot;com.myapp.appname&quot;, attributes: DispatchQueue.Attributes.concurrent)<br><br>NSLog(&quot;Started wifi list scanning.&quot;)<br><br>NEHotspotHelper.register(options: options, queue: queue) { (cmd: NEHotspotHelperCommand) in<br>  NSLog(&quot;Received command: \(cmd.commandType.rawValue)&quot;)<br>}</pre><p>There are three command types that you need to be aware of to perform custom authentication.</p><ul><li><strong>NEHotspotHelperCommandType.filterScanList</strong> — iOS will call your closure with this command type when the user opens the WIFI Settings page. You can obtain a list of all available hotspots from the command. Your code needs to create a filtered list of hotspots that you will like to authenticate with. You also need to set the WIFI password for these hotspots at this point. Once the closure returns, iOS will show the display name below the filtered hotspots. The display name is set using the kNEHotspotHelperOptionDisplayName option as shown in the code above. Note: Filtering does not really remove other hotspots from the list in the WIFI settings page. It is simply meant to identify the networks that your app deems appropriate for authentication.</li><li><strong>NEHotspotHelperCommandType.evaluate</strong> — If the user taps on one of your filtered hotspots and makes a connection the closure is called again with an evaluate command. You can perform custom business logic to evaluate the connected hotspot. If it is appropriate, your code should set a high confidence level for the network.</li><li><strong>NEHotspotHelperCommandType.authenticate</strong> — After the evaluation phase the closure is called again with an authenticate command. Your code can now perform custom authentication logic and respond with a success or failure status. If successful the connection is finally established.</li></ul><p>Remember, your callback closure will only be called if the user opens the WIFI Settings page. Also, the user must manually initiate a connection to a hotspot. Your code can not automatically connect.</p><p>A sample code for the lambda can look like this.</p><pre>{ (cmd: NEHotspotHelperCommand) in<br>    NSLog(&quot;Received command: \(cmd.commandType.rawValue)&quot;)<br>    <br>    if cmd.commandType == NEHotspotHelperCommandType.filterScanList {<br>        //Get all available hotspots<br>        var list: [NEHotspotNetwork] = cmd.networkList! <br>        //Figure out the hotspot you wish to connect to<br>        let desiredNetwork : NEHotspotNetwork? = getBestScanResult(list) <br><br>        if let network = desiredNetwork {<br>            network.setPassword(&quot;password&quot;) //Set the WIFI password<br><br>            let response = cmd.createResponse(NEHotspotHelperResult.success)<br><br>            response.setNetworkList([network])<br>            response.deliver() //Respond back with the filtered list<br>        }<br>    } else if cmd.commandType == NEHotspotHelperCommandType.evaluate {<br>        if let network = cmd.network {<br>            //Set high confidence for the network<br>            network.setConfidence(NEHotspotHelperConfidence.high) <br><br>            let response = cmd.createResponse(NEHotspotHelperResult.success)<br>            response.setNetwork(network)<br>            response.deliver() //Respond back<br>        }<br>    } else if cmd.commandType == NEHotspotHelperCommandType.authenticate {<br>        //Perform custom authentication and respond back with success<br>        // if all is OK<br>        let response = cmd.createResponse(NEHotspotHelperResult.success)<br>        response.deliver() //Respond back<br>    }<br>}</pre><p>For additional details about the different command types, see the <a href="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/Hotspot_Network_Subsystem_Guide/Contents/CommandHandlingDetails.html#//apple_ref/doc/uid/TP40016639-CH4-SW1">official document</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf92a6ed7b72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Carthage — iOS Dependancy Manager]]></title>
            <link>https://medium.com/@prvaghela/carthage-ios-dependancy-manager-13d4efa1900a?source=rss-b2de3a5c7789------2</link>
            <guid isPermaLink="false">https://medium.com/p/13d4efa1900a</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[carthage]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Paresh Vaghela]]></dc:creator>
            <pubDate>Wed, 29 Jun 2016 05:58:58 GMT</pubDate>
            <atom:updated>2016-06-29T05:58:58.030Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://cocoapods.org/">CocoaPods</a> are extensively wonderful but there is another option as well. <a href="https://github.com/Carthage/Carthage">Carthage</a> is one of them for any cocoa application either iOS or Mac. It is tremendously easy to use compare to CocoaPods. It is developed by group of developers from Github. What I most like about it is — It is the first dependancy manager to work with Swift; and It is developed in Swift Language. We all know Apple has already started emphasis towards Swift so It will be better to get to know about <a href="https://github.com/Carthage/Carthage">Carthage</a>.</p><p><strong>1. Install Carthage in your computer</strong></p><p>Download latest version from <a href="https://github.com/Carthage/Carthage/releases">https://github.com/Carthage/Carthage/releases</a>. Double-click Carthage.pkg to run the installer. Click Continue, select a location to install to, then click Continue again, and finally click Install.</p><p>You can also use <a href="http://brew.sh/">Homebrew</a> and install it simply by running <em>brew update</em> and <em>brew install carthage</em>.</p><p>Run <em>carthage version </em>command to ensure, it is perfectly installed on your system or not. It will display like 0.16.2.</p><p><strong>2. Create Cartfile in your project directory</strong></p><p>Run below commands :</p><p>cd ~/Path/Project</p><p>touch Cartfile</p><p>open -a Xcode Cartfile</p><p>github “Alamofire/Alamofire” == 2.0</p><p>github “SwiftyJSON/SwiftyJSON” ~&gt; 2.3.0</p><p><strong>3. Build Dependancy</strong></p><p>Run below command to create required framework into your project directory.</p><p>carthage update –platform iOS</p><p>For more help on update command, use <em>carthage help update</em> for details.</p><p><strong>4. Add Frameworks to your project</strong></p><p>By default, Carthage will perform its checkouts and builds in a new directory named <em>Carthage</em> in the same location as your Cartfile. Open up this directory now by running:</p><p>open Carthage</p><p>You should see a Finder window pop up that contains two directories: <em>Build</em> and <em>Checkouts</em>. Take a moment to see what Carthage created for you.</p><p>Select the Project’s <em>target</em>, choose the <em>General</em> tab at the top, and scroll down to the <em>Linked Frameworks and Libraries</em> section at the bottom.</p><p>In the <em>Carthage</em> Finder window, navigate into <em>Build</em>\<em>iOS</em>. Now, drag both <em>Alamofire.framework</em> and<em>SwiftyJSON.framework</em> into the Linked Frameworks and Libraries section in Xcode.</p><p>Next, switch over to <strong>Build Phases</strong> and add a new <strong>Run Script</strong> build phase. Add the following command:</p><p>/usr/local/bin/carthage copy–frameworks</p><p>Click the <strong>+</strong> under <strong>Input Files</strong> and add an entry for each framework:</p><p>$(SRCROOT)/Carthage/Build/iOS/Alamofire.framework</p><p>$(SRCROOT)/Carthage/Build/iOS/SwiftyJSON.framework</p><p>Strictly speaking, this build phase isn’t <strong>required</strong> for your project to run. <em>However</em>, it’s a slick workaround for an <a href="http://www.openradar.me/radar?id=6409498411401216">App Store submission bug</a> where apps with frameworks that contain binary images for the iOS simulator are automatically rejected.</p><p>Congratulations, you’ve learnt about the philosophy behind dependency management and behind Carthage itself, gained some experience using Carthage to add some dependencies to a project, and used those dependencies to make a useful app!</p><p>You also know how to update your dependencies for future releases.</p><p>If you want to learn more about Carthage, your first stop should be the <a href="https://github.com/Carthage/Carthage">Carthage README</a> and the documentation on <a href="https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md">Build Artifacts</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13d4efa1900a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>