Giter Club home page Giter Club logo

swift-network-manager-example's Introduction

Swift Concurrency Network Manager

To see how the network request were made. Look at the code in the SPM SwiftNetworkManager

Example repo using Network Manager from https://github.com/Muhammed9991/SwiftNetworkManager.

As part of this project, I create a login and log out screen (see below). The API I was using in this was a locally hosted API created using FastAPI from this (highly reccomended) tutorial https://www.youtube.com/watch?v=0sOvCWFmrtA&t=33685s, written in python.

In the API I created all endpoints were protected using a JWT token. To access any data I needed to complete some authentication, receive a JWT token and use this to access data. The login screen was created for this. These are the following responsibility of the login screen:

  • Authentication
    • Succesful
      • Show "Login succeeded!" banner
      • Recieve token from API
      • Store token in keychain
      • Store username in keychain (for token refresh)
      • Store password in keychain (for token refresh)
      • Navigate to next screen, wehere two API reqeust are made:
        • To get some text from the data base (See code)
        • To get an image
    • Failure:
      • Show "Information not correct. Try again."

When the user clicks on the logout button. These are following things that happen:

  • Username deleted from keychain
  • Password deleted from keychain
  • Token deleted from keychain
  • Navigate back to login screen

Note: the login and logout screen were pretty basic, there is no validation check to see if email address is correct format etc. This was only created to test the network manager.

Login Screen Logout Screen
login logout

Future work:

  • Write unit tests for network manager (maybe mocking?)
  • Some refactor work is needed
  • Not the best errors were thrown in certain scenarios.
  • Add REGEX check to see if valid email adress. Basically more checks on login screen.

swift-network-manager-example's People

Contributors

muhammed9991 avatar

Stargazers

YuSeF avatar Prokhorov Maksim  avatar Kyle2501 avatar Narcis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.