Swift managers package for the easiness of working with the various services.

Overview

SwiftManagers

Description

Swift managers package for the easiness of working with the various services.

Installation

Just Download the folder of the desired manager, unzip and copy files to your project.

Samples and Example Usage

FirebaseAuth

AuthManager.shared.login(email: "email", password: "pass") { result in
    switch result {
    case .success(let user):
        print(user.providerID)
    case .failure(let error):
        print(error.localizedDescription)
    }
}

AuthManager.shared.register(email: "email", password: "pass", confirmPassword: "pass") { result in
    switch result {
    case .success(let user):
        print(user.providerID)
    case .failure(let error):
        print(error.localizedDescription)
    }
}

AuthManager.shared.resetPassword(email: "email") { result in
    switch result {
    case .success(_):
        print("success")
    case .failure(let error):
        print(error.localizedDescription)
    }
}

AuthManager.shared.logout()

FirebaseStorage

<- Here you must specify the ID of the user you want to download from. StorageManager.shared.upload(userPhoto: userImage, userId: id) { (result) in switch result { case .success(let url): print(url.absoluteString) case .failure(let error): print(error.localizedDescription) } } ">
let userImage = UIImage() // <- Here should be the image you want to upload.
let id = "USER_ID" // <- Here you must specify the ID of the user you want to download from.

StorageManager.shared.upload(userPhoto: userImage, userId: id) { (result) in
    switch result {
    case .success(let url):
        print(url.absoluteString)
    case .failure(let error):
        print(error.localizedDescription)
    }
}
guard let url = URL(string: "URL_STRING_TO_IMAGE") else { return }

StorageManager.shared.downloadImage(url: url) { (result) in
    switch result {
    case .success(let image):
        print("success")
    case .failure(let error):
        print(error.localizedDescription)
    }
    
}

FirebaseFirestore

let user = Auth.auth().currentUser! // <- There must be a class User object here.
 // For example when you get a user in the response after registering Firebase.

FirestoreManager.shared.getUserData(user: user) { (result) in
    switch result {
    case .success(let firestoreUserModel):
        print(firestoreUserModel.firstName)
    case .failure(let error):
        print(error.localizedDescription)
    }
}
let user = FirestoreUserModel() // <- There must be a class FirestoreUserModel object here.
// For example when you get a user in the response after registering Firebase.

FirestoreManager.shared.saveProfile(user: user, userImage: nil) { (result) in
    switch result {
    case .success(let firestoreUserModel):
        print(firestoreUserModel.firstName)
    case .failure(let error):
        print(error.localizedDescription)
    }
}

NetworkingAlamofire

  • First create a request method in the NetworkManager.swift file.
func exampleRequest(completion: @escaping (Result?, Error>) -> Void) {
    guard let url = URL(string: "API_URL_STRING") else { return }
    var request = URLRequest(url: url)
    request.httpMethod = "GET"
    
    // If the request contains headers.
    let headers = ["EXAMPLE_API_HEADER_KEY" : "EXAMPLE_API_HEADER_VALUE",
                   "EXAMPLE_API_HEADER_KEY" : "EXAMPLE_API_HEADER_VALUE"]
    request.allHTTPHeaderFields = headers
    
    // If the request contains parameters.
    let params = ["EXAMPLE_API_PARAMS_KEY" : "EXAMPLE_API_PARAMS_VALUE",
                  "EXAMPLE_API_PARAMS_KEY" : "EXAMPLE_API_PARAMS_VALUE"]
    let data = try? JSONSerialization.data(withJSONObject: params, options: [])
    request.httpBody = data
    
    AF.request(request).responseJSON { (response) in
        switch response.result {
        case .success(_):
            completion(.success(response.data))
        case .failure(let error):
            completion(.failure(error))
        }
    }
}
  • After, you will be able to call anywhere with a short request.
NetworkManager.shared.exampleRequest { result in
    switch result {
    case .success(let data):
        print("success")
    case .failure(let error):
        print(error.localizedDescription)
    }
}
  • Additionally, you can parse the received date to your class object.

    • Create a model based on the query response in the file ExampleModel.swift
    • Sign all structures to protocol Codable <- REQUIRED.
    • See example in the file ExampleModel.swift
guard let data = data else { return }
if let object = NetworkHelpers.shared.parseExampleModel(data) {
    print(object.name)
}

NetworkingURLSession

  • First create a request method in the DataFetcherManager.swift file.
func exampleRequest(completion: @escaping (ExampleModel?) -> Void) {
    let urlString = "API_URL_STRING"
    dataFetcher.fetchJSONData(urlString: urlString, headers: nil, response: completion)
}
  • Create a model based on the query response in the file ExampleModel.swift
  • Sign all structures to protocol Codable <- REQUIRED.
struct ExampleModel: Codable {
    let main: Main
    let name: String
}

struct Main: Codable {
    let firstValue: Double
    let secondValue: Double
}
  • After, you will be able to call anywhere with a short request.
var dataFetcherManager = DataFetcherManager()

dataFetcherManager.exampleRequest { exampleModel in
    guard let exampleModel = exampleModel else { return }
    print(exampleModel.name)
}

Created by Oleksandr Kurtsev (Copyright © 2021) LICENSE

You might also like...
Very simple swift wrapper for Biometric Authentication Services (Touch ID) on iOS.

SimpleTouch Very simple swift wrapper for Biometric Authentication Services (Touch ID) on iOS. Sample Project There is a SimpleTouchDemo target define

Modern Swift wrapper for Keychain Services API with the benefits of static typing

SwiftyKeychainKit SwiftyKeychainKit is a simple Swift wrapper for Keychain Services API with the benefits of static typing. Define your keys in one pl

ViperServices - Simple dependency injection container for services written for iOS in swift supporting boot order

ViperServices Introduction ViperServices is dependency injection container for iOS applications written in Swift. It is more lightweight and simple in

Publish and discover services using Bonjour

Ciao Lib to publish and find services using mDNS Requirements Installation Usage License Requirements iOS 8.0+ / Mac OS X 10.10+ / tvOS 9.0+ Xcode 9.0

Exposing macOS Services through a Catalyst app
Exposing macOS Services through a Catalyst app

CatalystServices This is a simple example to show how you can implement the macOS Services system in your Catalyst app. The services you expose are pr

Simple OAuth2 library with a support of multiple services.

Simple OAuth2 library with a support of multiple services.

A Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11.
A Location Manager for easily implementing location services & geofencing in iOS. Ready for iOS 11.

A Location Manager for easily implementing location services & geofencing in iOS, written in Objective-C. Ready for iOS 11. Features Get current/conti

This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app.
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app.

This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and Apple TV app. With this Framework you can create iPh

Enumerate Location Services using CoreLocation API on macOS
Enumerate Location Services using CoreLocation API on macOS

SwiftLiverpool Description This tool leverages the CoreLocation API on macOS to enumerate Location Services data. You need to enable "Location Service

Request the Location Services via a 3D 360° flyover MKMapView 🗺
Request the Location Services via a 3D 360° flyover MKMapView 🗺

STLocationRequest STLocationRequest is a simple and elegant way to request the users location services at the very first time. The STLocationRequestCo

A mobile application project designed for everybody which provides the easiest way to make searchs for public services
A mobile application project designed for everybody which provides the easiest way to make searchs for public services

A mobile application project designed for everybody which provides the easiest way to make searchs for public services

Wi-attack: Cross-technology Impersonation Attack against iBeacon Services

Wi-attack: Cross-technology Impersonation Attack against iBeacon Services

Smart Online Shopping iOS App with Augmented Reality (AR) and simple Social Media features using SwiftUI and Google Firebase Cloud Services
Smart Online Shopping iOS App with Augmented Reality (AR) and simple Social Media features using SwiftUI and Google Firebase Cloud Services

Table of contents App Demo How to Run Context Content How it's written Inspiration App Demo AR.online.shopping.iOS.demo.mp4 How to Run First make sure

SwiftOverlays is a Swift GUI library for displaying various popups and notifications
SwiftOverlays is a Swift GUI library for displaying various popups and notifications

SwiftOverlays is a Swift GUI library for displaying various popups and notifications. SwiftOverlays animated logo is kindly made by Crafted Pixels Fea

 GUI library for displaying various popups (HUD), written in pure Swift.
GUI library for displaying various popups (HUD), written in pure Swift.

SwiftNotice SwiftNotice is a GUI library for displaying various popups (HUD) written in pure Swift, fits any scrollview and supports iPhone X. Feature

Simple implementations of various dynamic data structures in Swift.

SwiftDataStructures Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installatio

Swift framework for loading various 3d models in SceneKit

AssetImportKit AssetImportKit is a cross platform library (macOS, iOS) that coverts the files supported by Assimp to SceneKit scenes. Features AssetIm

A swift library based on the various options menu in material design in Android
A swift library based on the various options menu in material design in Android

KTOptionMenu Description KTOptionMenu is a swift library based on the various options menu in material design in Android that allows you to easily cre

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

Releases(1.0.0)
Owner
Oleksandr Kurtsev
👨🏻‍💻 I'm a Mobile Developer
Oleksandr Kurtsev
The Swift Package Manager made at Magascar Coding Club

HSKit It's the Swift Package Manager made at Magascar Coding Club. Installation Swift Package Manager The Swift Package Manager is a tool for automati

hyesu kim 1 Dec 4, 2021
A Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility.

Keychain Manager Keychain Manager is a Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness

Gokul Nair 14 Jan 1, 2023
AnalyticsKit for Swift is designed to combine various analytical services into one simple tool.

?? AnalyticsKit AnalyticsKit for Swift is designed to combine various analytical services into one simple tool. To send information about a custom eve

Broniboy 6 Jan 14, 2022
CZWeatherKit is a simple, extensible weather library for iOS, tvOS, and OS X that allows for easy fetching of weather data from various weather services.

CZWeatherKit is a simple, extensible weather library for iOS, tvOS, and OS X that allows for easy fetching of weather data from various weather services.

Comyar 455 Nov 20, 2022
A Swift package for working with probability-driven randomness

ControlledChaos ControlledChaos is a simple Swift package for working with proba

B.T. Franklin 2 Dec 31, 2022
Use this package in order to ease up working with Combine URLSession.

Use this package in order to ease up working with Combine URLSession. We support working with Codable for all main HTTP methods GET, POST, PUT and DELETE. We also support MultipartUpload

Daniel Mandea 1 Jan 6, 2022
Demonstration code for a simple Swift property-wrapper, keypath-based dependency injection system. The keypaths ensure compile-time safety for all injectable services.

Injectable Demo Preliminary musings and demonstration code for a simple Swift property-wrapper, keypath-based dependency injection system. The keypath

Michael Long 12 Aug 5, 2022
Swift APIs for getting book information from popular web services

Swift APIs for getting book information from popular web services

Brian Dewey 1 Sep 25, 2021
Easy to use SMJobBless, along with a full Swift implementation of the Authorization Services and Service Management frameworks

Leverage SMJobBless functionality with just one function call: let message = "Example App needs your permission to do thingamajig." let icon = Bundle.

null 20 Dec 23, 2022