<?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 Amit Thakur on Medium]]></title>
        <description><![CDATA[Stories by Amit Thakur on Medium]]></description>
        <link>https://medium.com/@amitkthakur?source=rss-fc88637da3c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qyYwEv4U8oCjYc5j20RSOA.png</url>
            <title>Stories by Amit Thakur on Medium</title>
            <link>https://medium.com/@amitkthakur?source=rss-fc88637da3c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:28:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amitkthakur/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[SOLID Design Principles]]></title>
            <link>https://amitkthakur.medium.com/s-o-l-i-d-principles-fae591c6219c?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fae591c6219c</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-design]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Wed, 23 Apr 2025 00:52:01 GMT</pubDate>
            <atom:updated>2025-04-23T01:05:15.842Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*va8z3DLn1KnHRjCpygEPqg.png" /></figure><p>SOLID Principles, proposed by <em>Robert C. Martin,</em> are a set of principles which allow us to create stable applications with better design and clean manageable code.</p><p>🎯 <strong>Key Purposes of SOLID</strong></p><ul><li>🛠️ <em>Easy code maintenance</em></li><li>🔄 <em>Clean, Modularized Code</em></li><li>🤝 <em>Improves Team Collaboration</em></li><li>🔌 <em>Supports Dependency Injection</em></li><li>🧪 <em>Improves Testability</em></li><li>📈 <em>Improves Scalability</em></li></ul><p>SOLID is an acronym which stands for the following principles:</p><h4>SINGLE RESPONSIBILITY PRINCIPLE</h4><blockquote><strong>The Single Responsibility Principle states that any class, module or function should have its responsibility aligned towards a single part of the functionality. All services provided by the item should be narrowly aligned with the functionality.</strong></blockquote><p><em>What does it imply?</em></p><p>It implies that the responsibilities of classes should be singular and focused towards functionality.</p><p><em>Some of the benefits are:</em></p><ul><li>It limits the amount of functionality incorporated by the class.</li><li>It keeps our code more readable.</li><li>It limits the amount of change accepted by the class or any other dependent classes.</li></ul><p><em>Example:</em></p><p>❌ Bad Example</p><pre>class OnboardingViewController {    <br>    func skipButtonTapped() {<br>        dismissThis()<br>        analytics.logEvent(.onboardingSkipped)<br>    }<br>    <br>    private func dismissThis() {<br>        print(&quot;Onboarding flow dismissed.&quot;)<br>    }<br><br>    func logOnboardingSkippedEvent() {<br>        let eventName = &quot;onboarding_skipped&quot;<br>        // add logic here to send the event to analytics data store<br>    }<br>}</pre><p>✅ Good Example</p><pre>enum AnalyticsEvent {<br>    case onboardingSkipped<br>    <br>    func eventName() -&gt; String {<br>        switch self {<br>        case .onboardingSkipped:<br>            return &quot;onboarding_skipped&quot;<br>        }<br>    }<br>}<br><br>// Analytics class responsible for logging events<br>class AnalyticsTracker {<br>    func logEvent(_ event: AnalyticsEvent) {<br>        let eventName = event.eventName()<br>        // add logic here to send the event to analytics data store<br>    }<br>}<br><br>// ViewController handling UI logic and interacting with Analytics<br>class SolidOnboardingViewController {<br>    let analytics = AnalyticsTracker()<br>    <br>    func skipButtonTapped() {<br>        dismissThis()<br>        analytics.logEvent(.onboardingSkipped)<br>    }<br>    <br>    private func dismissThis() {<br>        print(&quot;Onboarding flow dismissed.&quot;)<br>    }<br>}</pre><h4>OPEN CLOSED PRINCIPLE</h4><blockquote><strong>The Open Closed Principle states that a class, module or functionality should be open for extension but closed for modification.</strong></blockquote><p><em>What does it imply?</em></p><p>It implies that the behaviour of any class should not be modified directly. This is to preserve its existing functionality. If we want to add new functionality or modify a functionality, we should extend the class by using inheritance, extensions or interfaces.</p><p><em>Some of the benefits are:</em></p><ul><li>This principle safeguards the original behaviour of our class, module or function.</li><li>Better scalability and reusability</li></ul><p><em>Example:</em></p><p>✅ Good Example</p><pre>extension String {<br>    func asHandle() -&gt; String {<br>        return &quot;@\(self)&quot;<br>    }<br>    <br>    func asHashtag() -&gt; String {<br>        return &quot;#\(self.replacingOccurrences(of: &quot; &quot;, with: &quot;&quot;))&quot;<br>    }<br>}</pre><h4>LISKOV SUBSTITUTION PRINCIPLE</h4><blockquote><strong>Liskov Substitution Principle states that any subclass should fulfil all the expected behaviour of its base class.</strong></blockquote><p><em>What does it imply?</em></p><p>This means that a subclass should not modify the original behaviour of its base class. It should extend or enhance the behaviour so that we can replace all base class objects with subclass objects without any exceptions.</p><p><em>Some of the benefits are:</em></p><ul><li>Makes polymorphism safe from exceptions.</li><li>Supports clean inheritance and protocol-oriented design.</li></ul><p><em>Example:</em></p><p>❌ Bad Example</p><pre>struct MessageSender {<br>    func sendText(message: String) {<br>        print(&quot;💬 Text Message: \(message)&quot;)<br>    }<br><br>    func sendChat(message: String) {<br>        print(&quot;💬 Chat: \(message)&quot;)<br>    }<br><br>    func sendEmail(message: String) {<br>        print(&quot;📧 Email: \(message)&quot;)<br>    }<br><br>    func sendPush(message: String) {<br>        print(&quot;🔔 Push Notification: \(message)&quot;)<br>    }<br>}</pre><p>✅ Good Example</p><pre>protocol MessageSender {<br>    func send(message: String)<br>}<br><br>struct TextMessageSender: MessageSender {<br>    func send(message: String) {<br>        print(&quot;💬 Text Message: \(message)&quot;)<br>    }<br>}<br><br>struct ChatSender: MessageSender {<br>    func send(message: String) {<br>        print(&quot;💬 Chat: \(message)&quot;)<br>    }<br>}<br><br>struct EmailSender: MessageSender {<br>    func send(message: String) {<br>        print(&quot;📧 Email: \(message)&quot;)<br>    }<br>}<br><br>struct PushNotificationSender: MessageSender {<br>    func send(message: String) {<br>        print(&quot;🔔 Push Notification: \(message)&quot;)<br>    }<br>}</pre><h4>INTERFACE SEGREGATION PRINCIPLE</h4><blockquote><strong>The Interface Segregation Principle states that class interface should be broken down into role-based interfaces.</strong></blockquote><p><em>What does it imply?</em></p><p>A <em>Role Interface</em> provides/exposes specific functionality or behaviour which are relevant to the role being played.</p><p><em>Some of the benefits are:</em></p><ul><li>Focused interfaces with improved testability</li><li>Reduces unnecessary dependency and reduced complexity</li><li>Encourages Single Responsibility</li></ul><p><em>Examples:</em></p><p>❌ Bad Example</p><pre>protocol Protectable {<br>    func encrypt() -&gt; String<br>    func encode() -&gt; String<br>    func hash() -&gt; String<br>}</pre><p>✅ Good Example</p><pre>protocol Encryptable {<br>    func encrypt() -&gt; String<br>}<br><br>protocol Hashable {<br>    func hash() -&gt; String<br>}<br><br>protocol Encodable {<br>    func encode() -&gt; String<br>}</pre><h4>DEPENDENCY INVERSION PRINCIPLE</h4><blockquote><strong>The Dependency Inversion Principle suggests that high-level classes should not depend directly on low-level classes. Instead, both should depend on abstractions.</strong></blockquote><p><em>What does it imply?</em></p><p>This means that High-Level Classes should not be tightly coupled with Low-Level classes. This creates a strong dependency in our code and hence reduces the dynamic nature of our code.</p><p><em>Some of the benefits are:</em></p><ul><li>Prevents tight coupling and retain cycles.</li><li>Improves testability</li><li>Improves flexibility and easier to modify or extend</li></ul><p><em>Example:</em></p><p>❌ Bad Example</p><pre>class Communicator {<br>    private var preferredMessageSender = EmailSender()<br>    <br>    func notify(message: String) {<br>        preferredMessageSender.send(message: message)<br>    }<br>}</pre><p>✅ Good Example</p><pre>class SolidCommunicator {<br>    private var preferredMessageSender: MessageSender<br>    <br>    init(preferredMessageSender: MessageSender) {<br>        self.preferredMessageSender = notificationSender<br>    }<br>    <br>    func notify(message: String) {<br>        preferredMessageSender.send(message: message)<br>    }<br>}</pre><h4>🧑‍💻 IN MOBILE APP CONTEXT:</h4><ul><li>SOLID makes your app easier to test. Adopting <strong>protocols</strong>, and <strong>dependency injection</strong> is the way to go.</li><li>Helps build features independently.</li><li>Helps the team understand a <strong>well-structured codebase</strong>.</li></ul><p>In conclusion, always think of SOLID while designing apps as they will help you create <strong>better software</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fae591c6219c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Swift Programming: Structs vs Classes]]></title>
            <link>https://amitkthakur.medium.com/swift-programming-structs-vs-classes-2b5422396aae?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b5422396aae</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[structs-vs-classes]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 10:39:52 GMT</pubDate>
            <atom:updated>2023-06-13T11:04:39.329Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1vk0lhC6c0AorStCsnyx8w.png" /></figure><p><em>One of the most important concepts in Swift programming is to understand the difference between a structures and class. They are the building blocks of any application as they encapsulate data by defining methods and properties to provide functionality to our code.</em></p><h3><strong>What are structs?</strong></h3><p>Structs are <strong>value</strong> types. They are declared using the keyword <em>struct</em></p><pre>struct ElectricCar {<br>    var batteryRange: Int<br>    var topSpeed: Int<br>}</pre><h3><strong>What are classes?</strong></h3><p>Classes are <strong>reference</strong> types. They are declared using the keyword <em>class</em></p><pre>class ElectricCar {<br>    var batteryRange: Int<br>    var topSpeed: Int<br>}</pre><p>Not only do they look syntactically similar, there are many other similarities too.</p><h4><strong>What are the similarities between Structs and Classes?</strong></h4><ul><li><em>Both can have properties to store values.</em></li><li><em>Both can have methods to provide functionality.</em></li><li><em>Both can have initializers to define the initial state.</em></li><li><em>Both are open to extension.</em></li><li><em>Both can conform to a protocol.</em></li><li><em>Both can provide a subscript syntax to access values.</em></li></ul><p>Having said that, there are some fundamental differences between the two. Before we jump into them, let’s see what are the unique characterstics of each</p><h4><strong>What differentiates a class from a struct?</strong></h4><ul><li><em>Classes support inheritance.</em></li><li><em>Classes support type-checking.</em></li><li><em>Classes support deinitialisers which help us free memory assigned.</em></li><li><em>Classes allow reference counting which allow them to have more than one instance.</em></li></ul><h4><strong>What’s special about a struct?</strong></h4><ul><li><em>Doesn’t require initialisation. However, if required, we can provide a custom initialiser.</em></li><li><em>Doesn’t have inheritance. This makes them lightweight and provide better performance.</em></li></ul><blockquote>The fundamental difference between structs and classes are in their types. As we saw earlier, <em>structs</em> are value <em>types</em> whereas classes are reference type. Let’s see what this means</blockquote><h4><strong><em>What does value types mean?</em></strong></h4><p>Value types, when assigned or passed to a function, they create a new copy of the value and store it in a new location. A new instance is created and stored in the current memory stack. Modifying the struct doesn&#39;t modify the original value.</p><blockquote>Example:</blockquote><pre>struct ElectricCar {<br>    var batteryRange: Int<br>    var topSpeed: Int<br>}<br><br>var longRange = ElectricCar(batteryRange: 314, topSpeed: 145)<br>var performance = longRange<br>performance.topSpeed = 164<br><br>print(&quot;LONG RANGE::: Top Speed: \(longRange.topSpeed) mph Battery Range: \(longRange.batteryRange) mi&quot;)<br>print(&quot;PERFORMANCE::: Top Speed: \(performance.topSpeed) mph Battery Range: \(performance.batteryRange) mi&quot;)</pre><blockquote>Output:</blockquote><pre>LONG RANGE::: Top Speed: <strong>145</strong> mph Battery Range: 314 mi<br>PERFORMANCE::: Top Speed: <strong>164</strong> mph Battery Range: 314 mi</pre><p>The <em>topSpeed</em> of the <em>performance</em> variable updates but doesn’t overwrite the <em>longRange</em> variable. Thats because when <em>longRange</em> was assigned to <em>performance</em>, swift creates a copy of the value and stores it to a new location. Hence any modification to <em>performance</em> doesn’t impact the original <em>longRange</em> value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MH_DFpinLcPC6KK14WJZg.png" /></figure><h4><strong><em>What does reference types mean?</em></strong></h4><p>Reference types, when assigned or passed to a function, create a new reference to the existing instance. An instance is created in the heap memory and the reference points to this instance.</p><blockquote>Example:</blockquote><pre>class ElectricCar {<br>    var batteryRange: Int<br>    var topSpeed: Int<br>    <br>    //Required initialisers.<br>    init(batteryRange: Int, topSpeed: Int) {<br>        self.batteryRange = batteryRange<br>        self.topSpeed = topSpeed<br>    }<br>}<br><br>let longRange = ElectricCar(batteryRange: 314, topSpeed: 145)<br>let performance = longRange<br>performance.topSpeed = 164<br><br>print(&quot;LONG RANGE::: Top Speed: \(longRange.topSpeed) mph Battery Range: \(longRange.batteryRange) mi&quot;)<br>print(&quot;PERFORMANCE::: Top Speed: \(performance.topSpeed) mph Battery Range: \(performance.batteryRange) mi&quot;)</pre><blockquote>Output:</blockquote><pre>LONG RANGE::: Top Speed: <strong>164</strong> mph Battery Range: 314 mi<br>PERFORMANCE::: Top Speed: <strong>164</strong> mph Battery Range: 314 mi</pre><p>The <em>topSpeed</em> of the <em>performance</em> and <em>longRange</em> variable point to the same instance of <em>Car</em>. So when we perform any modification, it modifies the instance. As there is only one instance, the modification is reflected when we try to access via the other reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bRLCstdRDa15rpvwHc8rww.png" /></figure><h4><strong><em>Some other interesting features about Reference type:</em></strong></h4><ul><li><em>It also increases the reference count of the original value. Hence, its important to deinitialise any unwanted references.</em></li><li><em>Reference Types </em><em>longRange and </em><em>performance are declared as a </em><em>constant The compiler allows us to modify their properties because the constants dont actually change. Its the reference instance which changes.</em></li><li><em>Swift provides us with </em><strong><em>Identity Operators</em></strong><em> which allow us to compare two Instance Types. Its represented by </em><em>===</em></li></ul><h3><strong>How do we choose between structs and classes?</strong></h3><ul><li><strong><em>Apple recommends we ‘Use structs by default’.</em></strong></li><li><em>Use structs for data modelling when you have a remote database which store the final state.</em></li><li><em>Use structs if you donot want to reflect the change globally. Since, structs are value types, their scope is limited locally. This hides our changes from other areas of the code. Also, it takes away the risk of accidently changing something globally and makes us more confident of our code.</em></li><li><em>If you are creating an inheritance pattern from scratch, use </em><strong><em>structs and protocols</em></strong><em> to create the pattern. Protocols are powerful enough to allow structs to adopt to any pattern.</em></li></ul><h4><strong>Scenarios where we need to use a class are as follows:</strong></h4><ul><li><em>When our code interacts with a Obj-C code.</em></li><li><em>When our code requires sharing instances. We can use a class when different part of our code uses a shared instance or keep track of state.</em></li><li><em>When our code requires full control over the state such as File Managers, DB Connections, Network Controllers etc</em></li></ul><p>References:</p><ul><li><a href="https://docs.swift.org/swift-book/documentation/the-swift-programming-language/classesandstructures">Apple Swift Programming Docs</a></li></ul><blockquote><em>Thanks for reading and do share any feedback.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b5422396aae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps : Principles and Practices]]></title>
            <link>https://amitkthakur.medium.com/devops-principles-and-practices-aee103303dd2?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/aee103303dd2</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devops-practice]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 13:23:58 GMT</pubDate>
            <atom:updated>2022-06-01T13:23:58.638Z</atom:updated>
            <content:encoded><![CDATA[<h3>DevOps : Principles and Practices</h3><p>DevOps is a philosophy which creates a ‘way of working’ with cohesion and improved collaboration between the Dev and Ops Team. Dev and Ops are the two main areas of any Software teams. They ensure high quality and faster delivery of software.</p><p>DevOps targets are improved collaboration and seamless functioning across the software development, IT operations and security teams. DevOps is designed to work side-by-side agile software development principles. It extends the continuous integration and deployment and produced higher value for customers.</p><h3>DEVOPS LIFECYCLE</h3><p>The Lifecycle of DevOps creates a continuous software evolution model. This encourages software development activities to be extended beyond the conventional boundaries and creates a seamless eco-system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iOUtQiCz93MbKi24IN5F5g.png" /></figure><h3>KEY DEVOPS COMPONENTS</h3><h4>Continuous Integration</h4><p>Continuous Integration is a key software engineering practice and a key component of Agile Software Development and DevOps. It can be defined as the step where, individual development work/code is tested and integrated with the wider code base. The outcome is reported to the team along with any anomaly identified.</p><p>CI enabled a gate-check for the development process. Through automation it ensures quality in the deliverable and early defect identification and monitoring.</p><h4>Continuous Delivery</h4><p>Continuous Delivery enabled a faster delivery of new features to customers. CD revolves around improving the time-to-market and RoI. With gated checks and deployment rings, it ensures that the stable deliverable can move through various stages of production deployment.</p><h4>Automation</h4><p>At the core of DevOps practices is Automation. Automation helps speed up the software engineering process by eliminating manual interventions and repetitive activities. By standardizing various activities, automation improves several key aspects of software.</p><p>Before DevOps, Software Development Lifecycle was filled with several manual processes such as infrastructure setups, setup system configurations, manual deployments and testing. The disadvantages of manual processes are:</p><p>· <em>High Error Vulnerability</em></p><p><em>· Unreliable</em></p><p><em>· Higher time to market.</em></p><p><em>· Dependencies with external teams</em></p><p><em>· Non standardized business processes</em></p><p>DevOps environments aim at creating a high-level automated end to end process for the Enterprise. The target is to automate the software development lifecycle and eliminating manual interventions.</p><blockquote><strong>Some key aspects of Automation in DevOps are:</strong></blockquote><blockquote>· Creating standardized business processes which enable and support automation</blockquote><blockquote>· Test Automation to improve quality and standards.</blockquote><blockquote>· Automate Deployments to reduce manual interventions and improve RoI and time-to-market.</blockquote><blockquote>· Automating Reporting and Monitoring to aid defect prevention, reduce down-time and ensure high customer satisfaction.</blockquote><h3>BENEFITS OF DEVOPS</h3><p>DevOps practices call for a higher collaboration amongst development, operations, security, business, and other teams. DevOps encourages developers to spend time on operations and support activities. This encourages developers to think beyond their traditional activities of delivering a functioning software and encourages them to understand about operations support for maintaining the software in production.</p><blockquote><strong>The key benefits of DevOps are:</strong></blockquote><blockquote>· Improve Quality and Stable environments</blockquote><blockquote>· Facilitates continuous release and deployment</blockquote><blockquote>· Lower risks, early problem identification and resolution.</blockquote><blockquote>· Infrastructure as a Code</blockquote><blockquote>· Reduced maintenance cost and time of delivery</blockquote><blockquote>· Increased RoI.</blockquote><h3>CONCLUSION</h3><p>Applying DevOps principles in engineering is an effective way to improve performance and make the app landscape more manageable. It improves the RoI and reduces the time to market. Adopting the principles of DevOps is critical to maintaining a flexible, manageable, and saleable app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aee103303dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup Grafana on an Ubuntu EC2 Instance]]></title>
            <link>https://amitkthakur.medium.com/setup-grafana-on-an-ubuntu-ec2-instance-49bed73ae89e?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/49bed73ae89e</guid>
            <category><![CDATA[reporting-services]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[grafana]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Wed, 23 Mar 2022 15:49:34 GMT</pubDate>
            <atom:updated>2022-03-23T15:49:34.295Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*hK9nm9Eauhqn8pT1tpaPCg.jpeg" /></figure><p><em>In my new role as a Full Stack DevOps Engineer (yes that! 😵‍💫), i had the opportunity to setup Grafana on an EC2 Instance. I thought sharing this would help others overcome some issues they might face..</em></p><h4>What is Grafana?</h4><p><a href="https://grafana.com/"><strong>Grafana</strong></a> is a <a href="https://en.wikipedia.org/wiki/Multi-platform">multi-platform</a> <a href="https://en.wikipedia.org/wiki/Open_source">open source</a> analytics and <a href="https://en.wikipedia.org/wiki/Interactive_visualization">interactive visualization</a> web application. It provides charts, graphs, and alerts for the web when connected to supported data sources. It supports several data sources such as MSSQL, MySQL, PostgreSQL, Influx, GCM etc.</p><p><a href="https://grafana.com/">Grafana</a> has two versions <a href="https://grafana.com/docs/grafana/latest/enterprise/"><em>Grafana Enterprise</em></a> and <a href="https://grafana.com/docs/grafana/latest/introduction/oss-details/"><em>Grafana Open Source Software</em></a><em>.</em></p><p><a href="https://grafana.com/docs/grafana/latest/enterprise/"><em>Grafana Enterprise</em></a><em> </em>is a commercial version and require licensing. It comes with advance data source capabilities and additional features such as fine grain access control, exporting as PDF etc.</p><p>Here we will try to use the Grafana OSS version.</p><h4>Install <a href="https://grafana.com/">Grafana</a></h4><p>Run the below commands, to install <a href="https://grafana.com/">Grafana</a></p><pre>$ sudo apt-get install -y gnupg2 curl</pre><pre>$ curl <a href="https://packages.grafana.com/gpg.key">https://packages.grafana.com/gpg.key</a> | sudo apt-key add -</pre><pre>$ sudo add-apt-repository “deb <a href="https://packages.grafana.com/oss/deb">https://packages.grafana.com/oss/deb</a> stable main”</pre><pre>$ sudo apt-get update</pre><pre>$ sudo apt-get -y install grafana</pre><h4>Start <a href="https://grafana.com/">Grafana</a></h4><p>Run the below commands, to start <a href="https://grafana.com/">Grafana</a></p><pre>sudo systemctl daemon-reload<br>sudo systemctl start grafana-server</pre><p>Run the below commands, to ensure that <a href="https://grafana.com/">Grafana</a> runs automatically at boot</p><pre>sudo systemctl enable grafana-server.service</pre><p>Run the below commands, to check the version of <a href="https://grafana.com/">Grafana</a> installed</p><pre>$ grafana-server –v</pre><h4>Check <a href="https://grafana.com/">Grafana</a> status</h4><p>Run the below commands, to verify the status of <a href="https://grafana.com/">Grafana</a> service:</p><pre>sudo systemctl status grafana-server</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wmz2AALCwe_qifFnk_QlCA.png" /></figure><p>Watch out for any error logs in case the service failed to start. An additional helpful tip is to check the grafana.log file. To do this run the tail command</p><pre>sudo tail /var/log/grafana/grafana.log</pre><p>This will display the latest logs from grafana. Any errors can be easily identified here.</p><h4>Run <a href="https://grafana.com/">Grafana</a> dashboard</h4><p>By default, <a href="https://grafana.com/">Grafana</a> is available on port 3000. To check if <a href="https://grafana.com/">Grafana</a> is working or not, run the following command</p><pre>curl -i http://localhost:3000</pre><p>This should output an reference to the login page.</p><p>If you navigate to <a href="http://localhost:3000/">http://localhost:3000</a> on a local browser, it should take you to the <a href="https://grafana.com/">Grafana</a> login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SJmb9EI42x1uSpDT_pvbFg.png" /></figure><blockquote>Since the default Username and Password for <a href="https://grafana.com/">Grafana</a> is admin, you may want to change this using the ‘Forgot your password’ option</blockquote><h4>Customise <a href="https://grafana.com/">Grafana</a></h4><p><a href="https://grafana.com/">Grafana</a> can be customised by updating the <em>grafana.ini</em> file stored at the below location</p><pre>/etc/grafana/grafana.ini</pre><p>This file allows us to specify and customise <a href="https://grafana.com/">Grafana</a>. Any line prefixed with a ; is commented.</p><blockquote>To set a custom domain and change the root url of <a href="https://grafana.com/">Grafana</a>, we can modify the file to set the values as below:</blockquote><pre>protocol = http<br>http_port = 3000<br>domain = grafana.atdomain.com<br>enforce_domain = true<br>root_url = http://grafana.atdomain.com</pre><blockquote>To run <a href="https://grafana.com/">Grafana</a> on HTTPS, we can modify the file as below:</blockquote><pre>protocol = https<br>http_port = 443<br>domain = grafana.atdomain.com<br>enforce_domain = true<br>root_url = <a href="https://grafana.atdomain.com/">https://grafana.atdomain.com</a><br>cert_file = /etc/grafana/fullchain.pem<br>cert_key = /etc/grafana/privkey.pem</pre><p>Running <a href="https://grafana.com/">Grafana</a> on HTTPS will also require us to generate a Certificate. This can be done easily using Let’s Encrypt. Once the cert and key is generated we can set the path in the file.</p><p>However, running <a href="https://grafana.com/">Grafana</a> on a port &lt; 1024 requires an additional change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XeRMfSG-MmvvE3RE5N66uQ.png" /><figcaption><a href="https://grafana.com/docs/grafana/latest/installation/rpm/">https://grafana.com/docs/grafana/latest/installation/rpm/</a></figcaption></figure><p>This should allows us to run Grafana on https with custom domain name and url. If you have a reverse proxy tool on the machine, you will need to make some changes to the proxy config as explained <a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-grafana-on-ubuntu-18-04#step-2-setting-up-the-reverse-proxy">here</a>.</p><p>Now that we have Grafana running, i am looking forward to creating my own dashboard. Hope this will be helpful.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49bed73ae89e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS App Tracking Transparency – Changes to how IDFA can be accessed.]]></title>
            <link>https://amitkthakur.medium.com/idfa-changes-in-apples-ios-14-5-7e79f3d9cc59?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e79f3d9cc59</guid>
            <category><![CDATA[apptrackingtransparency]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[idfa]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Sun, 09 May 2021 05:45:57 GMT</pubDate>
            <atom:updated>2021-06-13T05:13:43.393Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aj2IZR8O3O1avsUj1sl3jw.png" /></figure><p>Apple eco-system has always been considered a safe and trusted place for users. Apple has always ensured that apps maintain high standard of security and privacy for user’s data.</p><p>With <em>iOS 14.5</em>, Apple has introduced some updates to how apps handle user’s privacy and data Use. These changes will also be applicable to <em>iPadOS 14.5</em> and <em>tvOS 14.5</em>.</p><p>On <strong>App Store Connect</strong>, apps will have to describe their privacy practices.</p><blockquote>What data is collected? How is it used? Who is it shared with?</blockquote><p>On <strong>App Store</strong>, users will be able to view the app’s privacy practices before downloading the app.</p><blockquote>What data the app might collect and how is it used? Does the app collect user’s identity or Device ‘s Identity?</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*_ed5wSMVYlFzrqqAq1Urrg.png" /></figure><p>On <strong>iOS Apps</strong>, it will be mandatory to request user authorisation before accessing app related data for tracking the user and device.</p><h4>What is tracking?</h4><p>An app is considered to be tracking user data</p><ul><li>If the app displays targeted ads using data collected on other apps and websites.</li><li>If the app uses third party SDKs which combine data from multiple apps or shares the data with other ad networks for targeted advertising, retargeting user or measuring ad efficiency.</li><li>Sharing device location or email list with a data broker.</li></ul><p>The following is not considered as tracking and doesn’t require authorisation:</p><ul><li>When the data is stored only on the device and not sent off the device.</li><li>When the data is used for fraud detection or prevention or for security purposes.</li><li>When the data broker is a consumer reporting agency with the purpose of obtaining and reporting on consumer’s creditworthiness solely for credit determination</li></ul><h4><strong>What is IDFA?</strong></h4><p><strong>IDFA</strong> stands for <strong><em>Identifier for Advertisers. </em></strong>It was introduced in 2012 as a replacement of Device’s unique identifier (UDID) and MAC Address. Its a unique alphanumeric value assigned to Apple devices.</p><blockquote>IDFA may look like: 8R141K12T-3600–1HT9-AKT6–93919172DSMT</blockquote><h4><strong>How is IDFA used for Ad Targeting?</strong></h4><p>Advertising Tools, Ad Networks and Mobile Measurement Platforms (MMPs) use the IDFA to identify devices and users. This allows them to track user activity across apps and websites and present targeted ads.</p><blockquote>Ever wondered, why the ads on your favourite social apps bear a strong resemblance to your activities on your favourite retail app. This IDFA.</blockquote><p>IDFA enables advertisers and MMPs in the following:</p><ul><li>Ad Targeting</li><li>Campaign Measurement</li><li>Attribution</li></ul><h4><strong>What changes have been introduced to the IDFA in iOS 14.5?</strong></h4><p>Limit Ad Tracking (LAT), available in earlier versions of iOS, allowed users to opt out of targeted advertising. However, this only allowed user’s to enable or disable tracking on the device level. So, what’s new in iOS 14.5?</p><p>With iOS 14.5, Apple has made it mandatory for apps to request user authorisation to track their device i.e. request access to IDFA. There are two benefits:</p><ul><li>This provides user a greater control over their device IDFA. They can choose which apps can track their devices. They can update their authorisation permission in the Privacy section of the iOS Settings app.</li><li>The user has a greater visibility of apps tracking their device. If required, they can visit the App Store to understand how the app uses the data and take an educated decision.</li></ul><h4><strong>How apps can request tracking authorisation?</strong></h4><p>Apps can use the <a href="https://developer.apple.com/documentation/apptrackingtransparency">AppTrackingTransparency</a> framework to request tracking authorisation. Perform the below steps in your app XCode project:</p><ul><li>In the <em>Info.plist</em>, set up the <a href="https://developer.apple.com/documentation/bundleresources/information_property_list/nsusertrackingusagedescription">NSUserTrackingUsageDescription</a> message. This message will be used in the system prompt requesting permission for tracking authorisation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCgLPrO6DlQwJLgJhyekFg.png" /></figure><ul><li>Update the <em>AppDelegate.swift</em>, to request tracking authorisation. You will need to import the <a href="https://developer.apple.com/documentation/apptrackingtransparency">AppTrackingTransparency</a> framework. Its always a good practice to verify the <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/3547038-trackingauthorizationstatus">trackingAuthorizationStatus</a> before requesting one.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQ4oz1wmitHMjylL5A7vmg.png" /></figure><ul><li>The <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/3547037-requesttrackingauthorization">requestTrackingAuthorization(completionHandler:)</a> method presents a prompt requesting the user’s permission. The returned status i.e. <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus">AuthorizationStatus</a> can either be <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/authorized">authorized</a> or <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/denied">denied</a>.</li><li>If the user authorisation is <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/denied">denied</a>, the IDFA for the device will be zeroed out.</li><li>The status <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/notdetermined">notDetermined</a> indicates that the user has not been requested for authorisation</li><li>The status <a href="https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/restricted">restricted</a> indicates that the authorisation for tracking has been restricted on the device. This means the user has disabled <em>Allow apps to Request to Track</em> on the device.</li></ul><p>A prompt is displayed requesting authorisation to allow tracking:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*TF0Q14Zx8EZUxDEJBQWAWQ.png" /></figure><h4><strong>What do the changes mean?</strong></h4><p>Although the IDFA changes from Apple will not stop advertisers and apps from displaying ads, it will definitely reduce targeted advertising. It gives the user a greater control over their data and provides transparency since the developers are now required to provide detailed information about the usage and sharing of the user’s private data.</p><p>I am sure the AdTech companies must be coming up with a new way to link all the data collected. But, Cheers to Apple for trying to bring some power back to the users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e79f3d9cc59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS BackgroundTasks]]></title>
            <link>https://amitkthakur.medium.com/ios-backgroundtasks-435a8e58b9e0?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/435a8e58b9e0</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[background-task]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Tue, 28 Apr 2020 22:16:37 GMT</pubDate>
            <atom:updated>2020-04-29T20:46:27.503Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZyFnCGlEpFV9viJhd9NlYw.png" /></figure><p>As an iOS Developer, i always find that background execution is a limitation we have learned to live with while designing and implementing apps. There are several use cases which can benefit with apps allowed to execute in background.</p><p>With the introduction with iOS 13, Apple introduced the <a href="https://developer.apple.com/documentation/backgroundtasks"><em>Background Tasks</em></a> framework. This allows our apps to refresh content and perform small tasks while the app is in background.</p><p>Some important considerations while implementing Background Tasks are:</p><blockquote><strong>Power</strong>: The device battery level is a primary factor for backgroud tasks to be triggered. Also, while implementing our task, we should ensure that its informs the system of completion. This ensures that our task doesn’t drain power unnecessarily.</blockquote><blockquote><strong>Performance: </strong>Our task should be efficient and guarantee high performance. Avoid implementing unnecessary work in background and use GCD to</blockquote><p>Let’s see how we can request background tasks execution for our apps:</p><p><strong>Step 1: Enable Background Processing capability for our app</strong></p><p>Firstly, we need to enable Background Processing capability for our app. This is available under the Background Modes capability for the app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NgkEnER6XF_aLZcdIln7JA.png" /><figcaption>Step 2: Enable Background Processing in App Scheme</figcaption></figure><p><strong>Step 2: Add the Background Task Identifiers to info.plist</strong></p><p>We need to provide a unique identifier for our tasks and we have to specify the task identifiers in the <strong><em>info.plist</em></strong> under the Key <em>Permitted background task scheduler identifiers</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ddvuoPLHj6xkb-KF9wP7FA.png" /><figcaption>Step 2: Add task identifier to info.plist</figcaption></figure><p><strong>Step 3: Register the app for Background Processing</strong></p><p>We need to register our app for background tasks. There are two types of background tasks namely</p><ul><li><em>A </em><a href="https://developer.apple.com/documentation/backgroundtasks/bgprocessingtask"><em>BGProcessingTask</em></a> is typically a time consuming task which is expected to take time to complete.</li><li>A <a href="https://developer.apple.com/documentation/backgroundtasks/bgapprefreshtask"><em>BGAppRefreshTask</em></a><em> </em>is typically a short task for performing actions that can be completed quickly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZgzkB5o1Ipykt_dAn7yyQ.png" /></figure><p>To register our tasks, we need to specify the identifiers and a task block which will call a code that we want to execute in the background.</p><p>The method <em>handleAppRefresh(:)</em> is called when the system runs a task with the specified identifier “<em>com.amitthakur.sampleapp.refresh</em>”</p><p>The method <em>handleDataProcessing(:)</em> is called when the system runs a task with the specified identifier “<em>com.amitthakur.sampleapp.dataprocessing</em>”</p><p><strong>Step 4: Submit task for execution</strong></p><p>The next step is to <em>submit()</em> the task when the app goes to background. To do this, we fetch the request with the identifier specified.</p><p>With a <em>BGAppRefreshTask</em>, we need to specify an <em>earliestBeginDate</em> which tells the system when to execute the task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lcQ9DkDP8TqvVRFLQJXNPg.png" /><figcaption>Submit BGAppRefreshTask</figcaption></figure><p>With a <em>BGProcessingTask</em>, we should specify whether it <em>requiresNetworkConnectivity</em> and <em>requiresExternalPower. </em>These act as a pre-condition for our task execution and should be specified based on our task needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zlJfM29cY1zmIy7U3DzcvA.png" /><figcaption>Submit BGProcessingTask</figcaption></figure><p><strong>Step 5: Implement Task handler</strong></p><p>Now that we have registered our tasks, lets have a looks at how they work. Firstly, we reschedule our tasks so that we have another such task in the queue. This depends on whether your app expects periodic updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xOA7cNc8swjj9-HT5-BhdA.png" /><figcaption>Handle BGAppRefreshTask with expirationHandler</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFyWNHpa9fwHrRpwLzp0EQ.png" /><figcaption>Handle BGProcessingTask with expirationHandler</figcaption></figure><p>With every task execution we must specify a few things:</p><blockquote><strong>setTaskCompleted(success:)</strong> : <em>Use this to mark the task execution as complete.</em></blockquote><blockquote><strong>expirationHandler:</strong> <em>Use this to gracefully handle our task execution being terminated. Use this to perform cleanup or wrap up the task</em></blockquote><p><strong>Step 5: Schedule tasks when our app enters background</strong></p><p>Finally, don’t forget to schedule the tasks when our app enters background</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8euql08bEJPNxKpZovqgAA.png" /></figure><p>This should submit our tasks for execution in background.</p><p>In conclusion, having implemented background task execution in a few apps, it has definitely improved the app performance. However, triggering of the task is quite unpredictable. Apple has provided a way to invoke the task in debug mode, but more of that in the next blog on Background Tasks.</p><p>Hope this was helpful. Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=435a8e58b9e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ARKit : 101]]></title>
            <link>https://amitkthakur.medium.com/arkit-101-f6fe04322bfd?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6fe04322bfd</guid>
            <category><![CDATA[arkit]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[augmented-reality]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Sun, 29 Dec 2019 20:39:54 GMT</pubDate>
            <atom:updated>2019-12-29T20:39:54.909Z</atom:updated>
            <content:encoded><![CDATA[<h3>ARKit : 101</h3><p><em>Augmented Reality is a great way to engage your app users by providing them with an immersive experience. The combination of real and virtual world objects provides users a unique interactive experience.</em></p><p><em>With </em><a href="https://developer.apple.com/documentation/arkit"><strong><em>ARKit</em></strong></a><em> we can provide this experience for our iOS app users.The use cases of Augmented Reality are infinite.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eV6UVOahOpqKTxUQ7sGO5Q.png" /><figcaption>Image Credit: www.apple.com</figcaption></figure><blockquote><strong><em>Let’s start with a simple app.</em></strong></blockquote><p><em>Create a new Augmented Reality App in XCode.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HkAzFx-hiO_7Q_2NRZ8pQA.png" /></figure><p><em>This creates a XCode project with Augmented Reality capabilities. XCode asks us to choose a Content Technology for the application.</em></p><p><em>The app can use any of the below technologies:</em></p><ul><li><a href="https://developer.apple.com/documentation/realitykit"><strong><em>RealityKit</em></strong></a> : For implementing high-performance 3D simulation and rendering.</li><li><a href="https://developer.apple.com/documentation/scenekit"><strong><em>SceneKit</em></strong></a><em> : For 3D generated graphics.</em></li><li><a href="https://developer.apple.com/spritekit/"><strong><em>SpriteKit</em></strong></a><em> : For 2D generated graphics.</em></li><li><a href="https://developer.apple.com/metal/"><strong><em>Metal</em></strong></a><em> : Render advanced 3D graphics and perform data-parallel computations using graphics processors.</em></li></ul><p><em>In this case, we will use the </em><a href="https://developer.apple.com/documentation/scenekit"><em>SceneKit</em></a><em>, as we would like to create some 3D graphics.</em></p><blockquote><strong><em>Lets have a look at the ViewController.swift file</em></strong></blockquote><p><em>In the ViewController.swift file, lets add the below code to the viewDidLoad method.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ho096ujsKWyTqf7IKUSVrA.png" /></figure><p><em>The above code does the following:</em></p><ul><li><em>Sets up the ViewController as the delegate of the sceneView.</em></li><li><em>Allows the app to display fps and timing information at the bottom of the ARSCNView</em></li><li><em>Sets the debugOptions to display featurePoints i.e. the yellow dots on the plane.</em></li><li><em>Enables automaticallyUpdatesLighting and autoenablesDefaultLighting for the camera view.</em></li></ul><p><em>The view has a ARSession object associated with it. The ViewController.swift conforms to the ARSessionObserver protocol, providing the implementation of below methods:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c6Fs3BNphiB1merGPLlDxw.png" /></figure><blockquote><strong><em>Lets have a look at the Main.Storyboard</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zm2ks8zei1RacaeQWXZkvg.png" /></figure><p><em>The Storyboard has a ARSCNView embedded in the ViewController scene. The ARSCNView enables the app to create the Augmented Reality experience by blending virtual 3D content over the device camera view of the real world.</em></p><blockquote><strong><em>Lets render a SCNPlane object</em></strong></blockquote><p><em>Lets try to identify a plane which will act as a base to render graphical content. To do this we need to implement the ARSCNViewDelegate methods.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IRDhjLnS5WB9EltlUHO4ug.png" /></figure><p><em>The above delegates provide a call back identifying any update to the real world view. We will try to identify and display a plane on the camera.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVnQ_9dSiLhW6kh3urwosg.png" /></figure><p><em>The above code renders a gray colored plane and updates the plane as we move the device around.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*cfleqoCA7dWSG-ANTTyYHw.jpeg" /></figure><p><em>Once we have detected the plane, lets try to render 3D objects on the plane. There are several objects provided by SceneKit such as SCNBox, SCNSphere, SCNPyramid etc. Lets try to render a 3D object in the plane.</em></p><blockquote><strong><em>Render a 3D Box on the plane</em></strong></blockquote><p><em>To render a 3D Box, we will create a SCNBox object and provide the material properties like color and dimensions to the box object.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xq2lsEb4mM5_uv0a-VoRHA.png" /></figure><p><em>The above code renders a Box as depicted below</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*ImKcbAbawu36IjTfCtT_mg.jpeg" /></figure><blockquote><strong><em>Render a 3D Sphere on the plane</em></strong></blockquote><p><em>To render a 3D Sphere, we will create a SCNSphere object and provide the material properties like color and dimensions to the box object.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bQVt8TbZ-avLaKHe8MYZNw.png" /></figure><p><em>The above code renders a Box as depicted below</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*tAOuS0OoUCugLU6yDQvg2w.jpeg" /></figure><blockquote><strong><em>Display objects on Tap Gesture</em></strong></blockquote><p><em>To add a Tap Gesture to the view. In the viewDidLoad we will add a UITapGestureRecognizer object which will invoke a function on single tapping on the screen.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2cm-56lNsHzDXR55Xlnj-g.png" /></figure><p><em>Once we have added the Tap Gesture to the view, we can handle the tap gesture callback to render the item of our choice. I have tried adding a Box or a Sphere by calling the functions stated above</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVf86qI7zNSMd-Lu2x7dIA.png" /></figure><p><em>So having looked into some of the basic ARKit features, I am looking forward to creating an app which tries to implement a real world use case. However, more of that later. Thanks for reading. Hope you found this helpful. Watch this space for more!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6fe04322bfd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Conversation UI experience with SiriKit]]></title>
            <link>https://amitkthakur.medium.com/a-conversation-ui-experience-with-sirikit-f46b8b03da45?source=rss-fc88637da3c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f46b8b03da45</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[inrequestrideintent]]></category>
            <category><![CDATA[intent-framework]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[sirikit]]></category>
            <dc:creator><![CDATA[Amit Thakur]]></dc:creator>
            <pubDate>Thu, 11 Jul 2019 15:18:35 GMT</pubDate>
            <atom:updated>2019-07-11T15:18:35.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CZz4RJoDYDEHnLDQwAeugw.jpeg" /></figure><p><em>Conversation UI is the new way of enriching your user experience by allowing users to access your app content and performs actions by using their voice. The two main tasks are as follows:</em></p><ul><li><em>Capture users intent by understanding their voice</em></li><li><em>Respond to users intents through speakable responses.</em></li></ul><p><em>Conversation UI can revolutionise the way users use your apps. For iOS apps, this is where SiriKit comes into play.</em></p><p><em>SiriKit was first introduced by Apple in iOS 10. SiriKit allows iOS apps to work with Siri, Apple’s intelligent voice assistant. Siri performs the natural language processing and semantic analysis for you. Thus taking care of the difficult part.</em></p><p><em>To enable your apps to interact with Siri, you can use SiriKit by creating an Intents App Extension of your app and register for the domain specific intents your app wants to handle.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YFNqPZrkibdtsm5pHZtmQA.png" /></figure><p><em>Whenever your user makes a request to Siri, it does the natural language analysis and identifies the intent the user is trying to perform. Siri converts the spoken request into instructions that your application can handle.</em></p><p><em>Presently Apple has limited the SiriKit capabilities to the below mentioned domains:</em></p><ul><li><em>Audio/Video calling: Initiate calls and search call history.</em></li><li><em>CarPlay integration: Allows your app to interact with a vehicle’s CarPlay system.</em></li><li><em>Fitness activities: Allows users to start, pause or end a fitness activity.</em></li><li><em>List and Notes: Allows users to create and manage notes &amp; to-do lists.</em></li><li><em>Messaging: Allows users to send messages or search for messages received.</em></li><li><em>Payments: Allows users to send or receive payments.</em></li><li><em>Photo management: Allows users to search and display photos.</em></li><li><em>Ride booking: Allows users to book rides or check the status of rides booked.</em></li><li><em>Vehicle integration: Allows users to control their vehicle and perform actions like locking the doors or check on fuel/power level etc.</em></li><li><em>Visual codes: Shows visual codes like QR or barcode.</em></li></ul><p><em>If your application belongs to any of the above domains, you can use SiriKit to provide a conversation experience for your users to perform actions by just conversing with Siri. It also allows users to access your app features from lock screen or background.</em></p><p><em>Lets see how you can create a SiriKit extension for your iOS App for Requesting a Ride using Conversation UI.</em></p><p><em>Step 1: Enabling Siri Capabilities</em></p><p><em>You will need to enable Siri in your app capabilities.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMaamwG89giFaM1JX7iohg.png" /></figure><p><em>The next step is to request Siri authorisation.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucgxUMdrlIvGID4KdDV1-w.png" /></figure><p><em>Step 2: Adding an Intents App Extension</em></p><p><em>Add a new scheme to your application. Choose the “Intents Extension” options from XCode to add to your app. The “Intents UI Extension” is added by default. If you do not wish to add it, uncheck the option from the dialog which appears next.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b1V5EDjDwIHhkEdpW2SsBQ.png" /></figure><p><em>By adding the Intents Extension, the following files are added to your XCode project:</em></p><ul><li><em>IntentHandler.swift — Use this file to register your intent extension to an existing Intents domains or to new Intents created by you (more of that later).</em></li><li><em>IntentViewController.swift: This controller is used to provide a UI as response to user via Siri.</em></li><li><em>MainInterface.storyboard: As all storyboards, use this file to create your custom UI response.</em></li></ul><p><em>Step 3: Register for an Intent</em></p><p><em>To register for an intent you can use the “IntentHandler.swift” file. This file is a subclass of INExtension class. To register for an intent you need to make this class conform to any chosen intent.</em></p><p><em>The example i chose is for Requesting a Ride. My IntentHandler registers for INRequestRideIntentHandling. The file looks like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vljf3UJxJ2eN3VLfMYAA4Q.png" /></figure><p><em>Step 4: Resolve Intent Request Parameters</em></p><p><em>Whenever Siri gets a user request for a ride booking it tries to resolve the basic parameters to complete a ride booking i.e. Pickup location, drop-off location, party size, scheduled pickup times and ride options. The delegate methods invoked in your app extensions are needed to resolve the parameters.</em></p><p><em>This behaviour depends on how the user communicates their request to Siri.</em></p><p><em>A request might be</em></p><p><em>“Book a ride to London Heathrow Airport for one passenger at 9 AM tomorrow”</em></p><p><em>In the above statement the user has already provided the drop off location, party size and pickup time.</em></p><p><em>Another user might say</em></p><p><em>“Get me to London”</em></p><p><em>The intent extension must try to resolve all the parameters to successfully complete the request. This is where the delegate come in use.</em></p><p><em>If the user has provided the value for any of the parameter, we can accept it by providing a success response. Alternatively, you can ask Siri to confirm on the value provided by invoking a confirmationRequired request. Another option is to present some options to the user to disambiguate</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pde7EEexW2jm8gk9AlBELQ.png" /></figure><p><em>For partySize and scheduledPickupTime, if the user has specified the values, you can return a success response else you can ask Siri to resolve the value by specifying needsValue</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCjS6fr1G-LzJH4hkTsRUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ez8qXqcWZK54rDkrZrvvZQ.png" /></figure><p><em>Once all the required parameters are resolved, the extension needs to handle the intent and provide a confirmation to the user via Siri. Handling a request might be used to implement your business logic to complete the request.</em></p><p><em>To provide a confirmation to the user, you create a INRequestRideIntentResponse object with a userActivity and pass it as a completion to the SiriKit.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2FCTmhYQbsOg7PHB43mDw.png" /></figure><p><em>Step 5: Presenting a UI to user via Siri</em></p><p><em>Confirming an intent with a userActivity invokes your Intent UI Handler and presents a UI to the user. The IntentViewController looks like</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeRXl48jG5qNTuqiKS82kg.png" /></figure><p><em>Use the “configureView” method to display the values to the user. Once the user confirms the presented options, SiriKit allows your extension to complete the request.</em></p><p><em>Viola! The user can book a ride through your app by just having a conversation with Siri.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*-DLn2_Q3WZ45LfQPmWcFig.png" /></figure><p><em>Some things to keep in mind:</em></p><ul><li><em>Try to provide quick responses to the user. Responses should be speakable and crisp, keeping the user engaged.</em></li><li><em>Move all your network requests into a framework, keeping the intentHandler light weight.</em></li></ul><p><em>You can also add custom vocabulary to Siri or create Shortcuts to enhance your user experience. More of that in my next article.</em></p><p><em>Hope you enjoyed this one. Watch this space for more!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f46b8b03da45" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>