Skip to content

Instantly share code, notes, and snippets.

View atanasovdejan's full-sized avatar

Dejan Atanasov atanasovdejan

View GitHub Profile
@atanasovdejan
atanasovdejan / RateApp.swift
Created July 28, 2018 21:18
trigger rating and review screen using SKStoreReviewController
//
// RateApp.swift
// https://medium.com/@dejanatanasov
//
import Foundation
import StoreKit
class RateApp {
import UIKit
@objc protocol TestRoutingLogic
{
//func routeToSomewhere(segue: UIStoryboardSegue?)
}
protocol TestDataPassing
{
var dataStore: TestDataStore? { get }
import UIKit
protocol TestBusinessLogic
{
func fetchItems(request: Test.Fetch.Request)
}
protocol TestDataStore
{
//var name: String { get set }
import UIKit
protocol TestPresentationLogic
{
func presentFetchResults(response: Test.Fetch.Response)
}
class TestPresenter: TestPresentationLogic
{
weak var viewController: TestDisplayLogic?
import UIKit
protocol TestDisplayLogic: class
{
func successFetchedItems(viewModel: Test.Fetch.ViewModel)
func errorFetchingItems(viewModel: Test.Fetch.ViewModel)
}
class TestViewController: UIViewController, TestDisplayLogic
{
@atanasovdejan
atanasovdejan / firebase-podfile
Created August 3, 2018 21:46
Podfile for installing Firebase
platform :ios, '10.0'
target 'TARGET_NAME' do
use_frameworks!
inhibit_all_warnings!
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Database'
pod 'Firebase/Storage'
@atanasovdejan
atanasovdejan / FirebaseRegister.swift
Created August 3, 2018 22:34
Create user with Firebase Authentication
func createUser(email: String, password: String, _ callback: ((Error?) -> ())? = nil){
Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
if let e = error{
callback?(e)
return
}
callback?(nil)
}
}
@atanasovdejan
atanasovdejan / FirebaseLogin.swift
Created August 3, 2018 22:53
Login on Firebase
func login(withEmail email: String, password: String, _ callback: ((Error?) -> ())? = nil){
Auth.auth().signIn(withEmail: email, password: password) { (user, error) in
if let e = error{
callback?(e)
return
}
callback?(nil)
}
}
@atanasovdejan
atanasovdejan / FirebaseVerifyEmail.swift
Created August 4, 2018 08:38
Verify Email with Firebase
func sendEmailVerification(_ callback: ((Error?) -> ())? = nil){
Auth.auth().currentUser?.sendEmailVerification(completion: { (error) in
callback?(error)
})
}
@atanasovdejan
atanasovdejan / FirebaseReloadUser.swift
Created August 4, 2018 10:13
Firebase reload user details
func reloadUser(_ callback: ((Error?) -> ())? = nil){
Auth.auth().currentUser?.reload(completion: { (error) in
callback?(error)
})
}