An iOS App which shows live AQI (Air quality index) data for different cities using Web-socket

Related tags

Miscellaneous AQI
Overview

AQI - Assignment

This is an iOS App which shows live AQI (Air quality index) data for different cities using Web-socket.

Screenshots

Simulator Screen Shot - iPhone 13 - 2021-12-29 at 19 11 18 Simulator Screen Shot - iPhone 13 - 2021-12-29 at 19 12 11 Simulator Screen Shot - iPhone 13 - 2021-12-29 at 19 13 45 Simulator Screen Shot - iPhone 13 - 2021-12-29 at 19 44 30

Basic details

  • Deployment target: iOS 13.0
  • Supported device: iPhone & iPad
  • Code architecture: MVVM

Features

  • Live AQI data for 12 cities.
  • Detail screen which show live AQI chart for selected city.
  • History data upto 20 records.
  • Good chart data visulization & Zoom-in function.
  • Reconnection to Socket once user comes from App Background mode.
  • Dark mode support.
  • Error handling for Socket connection.

Note

  • For the sake of assignment, history is kept upto 20 records.
  • Suppose AQI value is 50.23 which lies between Good and Satisfactory Categoty. In that case, it is consider to be in Good category. We can change this logic as required.
  • Swift Packgae Manager (SPM) is used to manage project dependencies.

Architecture

  • MVVM code architecture pattern is used.

  • City list

    • ViewModel of City list connects to the web socket and listens to the callbacks.
    • It creates CityModel if it doesn't already exist (using city name) and adds AQIModel in aqi history array. If city already exist, it just adds AQIModel.
    • Once datasource is prepared, ViewModel updates View using delegate to refresh the table.
    • If there is error in socket connection, it updates View and user is promoted with error message with Retry button.
  • AQI chart for city

    • Once user select any city, it will pass CityModel to the detail screen. As data is shared among two screen, Class is used so it automatically refresh the chart.
    • View will ask ViewModel to prepare datasource based on history data and after Chart data is prepared, it will updates View using delegate to refresh the chart.
    • If there is an AQI update for selected city, ViewModel of City list will update ViewModel of chart view, which will updated the chart datasource and will update to View to refresh the chart.

Logic

  • Create city list

    • Response array is looped through and existing datasource is checked whether it contains a city with cityName. If not, new instance is created for city and AQI record is added to history.
    • AQICategory Enum is created based on the AQI value and each category is assigned Title and Color.
  • Create chart data

    • AQI history is looped through and array of ChartDataEntry is created and then Data set is created.
    • X-Axis time values are assigned through dataPoints array.
    • For the sake of demo and for better chart UI, only 20 records are stored for AQI history.
  • Reconnect Socket

    • Observers for didEnterBackgroundNotification and willEnterForegroundNotification are used to open and close the connection to Web-socket. If not used reconnection logic, it will stop getting Socket updates while coming back from App background mode.
You might also like...
A simple project that shows a list of local coffee shop reviews

Project This is a simple project that shows a list of local coffee shop reviews Details Please use git and commit often with meaningful commit message

Discover Movies and TV shows -  React Native
Discover Movies and TV shows - React Native

movieapp Discover Movies and TV shows Download APK file Download from Google Drive - v2.2.1 What's included Name Description React Native Build Native

Quotes shows you famous quotes to, hopefully, give you enlightment
Quotes shows you famous quotes to, hopefully, give you enlightment

"Quotes" shows you famous quotes to, hopefully, give you enlightment! You can also save/favorite the quotes that you liked to review later or show to your friends!

Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects
Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects

Introduction Respresso is a centralized resource manager for shared Android, iOS and Web frontend projects. It allows you to simply import the latest

Runtime Mobile Security (RMS) πŸ“±πŸ”₯  - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime
Runtime Mobile Security (RMS) πŸ“±πŸ”₯ - is a powerful web interface that helps you to manipulate Android and iOS Apps at Runtime

Runtime Mobile Security (RMS) πŸ“± πŸ”₯ by @mobilesecurity_ Runtime Mobile Security (RMS), powered by FRIDA, is a powerful web interface that helps you to

a playground app using `MultipeerConnectivity` to transfor data wirelessly between iOS / iPadOS

README An example app using MultipeerConnectivity to transfor data wirelessly between iOS / iPadOS. Both using Data and Stream to transfer data are su

PokePicker - a web application in JavaScript/VSCode with Google Firebase as the database

We would like to create a web application in JavaScript/VSCode with Google Firebase as the database. We want to make a Pokemon team creator

React Native Todo List example app which uses Redux for managing app state
React Native Todo List example app which uses Redux for managing app state

react-native-redux-todo-list A sample todo list app developed by using React Native and Redux. How to run the app Install react-native If you don't ha

Control Nvidia jetbot which is based on Jetson Nano via iOS app

jetbot-remote-control This is very basic example project which control Nvidia Jetbot remotely via iOS app Based on jetbot of Nvidia, adding sample sou

Owner
Pratik Prajapati
Pratik Prajapati
A simple project which shows how to pull off custom view controller transitions.

Custom View Controller Transitions This project explains and shows how to make custom view controller transitions in the most simple way possible. Eac

Jordan Morgan 91 Oct 23, 2022
Refresh your Live Activity with the "sound" background mode.

Live Activity Background Update Demo A demo about how to refresh Live Activity with the "sound" background mode. The Basics While in the background, L

Megabits_mzq 19 Dec 22, 2022
Example how to make, update and end Live Activity. With Dynamic Island and Lock Screen.

Live Activity Example Example how to make, update and end Live Activity. With Dynamic Island and Lock Screen. Full tutorial available at sparrowcode.i

Sparrow Code 9 Dec 8, 2022
A Simple way help you drop or drag your source (like UIImage) between different App.

A Simple way help you drop or drag your source (like UIImage) between different App.

ι€Έι£Ž 13 Nov 24, 2022
Codepath-flix - An iOS app that shows the movies currently playing in theaters

Flix App Submitted by: Luis Mora User Stories REQUIRED (10pts) (2pts) User sees

null 0 Mar 2, 2022
tvOS example app, shows upcoming movies

UpcomingMovies tvOS example app. Shows upcoming movies as a list and in a detail movie screen, using TMDb API. Installation Run pod install on project

Ivan Magda 32 Nov 10, 2022
Enables easy, convenient asynchronous asset loading in RealityKit for many different kinds of assets.

RealityKit Asset Loading Discussion This package includes classes and examples that enable easy, convenient asynchronous asset loading in RealityKit f

Grant Jarvis 7 Dec 23, 2022
This is a Swift Package bundling different Train APIs into one simple Swift interface.

This is a Swift Package bundling different Train APIs into one simple Swift interface.

ICE Buddy 8 Jul 5, 2022
The iOS pod which can collect profile data to detect code coverage.

CodeCoverageKit Installation CodeCoverageKit is available through CocoaPods.

木子 2 Sep 29, 2021
A web API client in Swift built using Async/Await

Web API Client A modern web API client in Swift built using Async/Await and Actors. let client = APIClient(host: "api.github.com") // Using the clien

Alexander Grebenyuk 741 Dec 30, 2022