This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // NetworkTask.swift | |
| // | |
| // Created by Fernando Ortiz on 2/11/17. | |
| // | |
| import Foundation | |
| import RxSwift | |
| class NetworkTask<Input: Request, Output>: Task<Input, Output> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // UIImage+Compression.swift | |
| // | |
| // Created by Fernando on 14/2/17. | |
| // Copyright © 2017 Fernando Martín Ortiz. All rights reserved. | |
| // | |
| import UIKit | |
| /// Intended to be used in UIImage size methods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protocol ReusableViewEnum {} | |
| extension ReusableViewEnum where Self: RawRepresentable, Self.RawValue == Int { | |
| static var all: [Self] { | |
| var index = 0 | |
| var allItems = [Self]() | |
| while let item = Self(rawValue: index) { | |
| allItems.append(item) | |
| index += 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public protocol AnalyticsService { | |
| /** | |
| 1. INITIALIZATION | |
| This will be called within AppDelegate application:didFinishLaunchingWithOptions: method | |
| In this method, you should initialize the SDK. | |
| */ | |
| func initialize(application: UIApplication, launchOptions: [UIApplicationLaunchOptionsKey: Any]?) | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| enum Event: Int { | |
| // Here is the list of events that you | |
| // want to track | |
| case loginWithEmail = 0 | |
| case loginWithFacebook | |
| case loginWithGoogle | |
| case registerWithEmail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import Mixpanel | |
| final class MixpanelAnalyticsService: AnalyticsService { | |
| // Account credentials | |
| private static let TOKEN = "Your token" | |
| // Initializes Mixpanel analytics when app launches | |
| func initialize(application: UIApplication, launchOptions: [UIApplicationLaunchOptionsKey: Any]?) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| final class AnalyticsManager: AnalyticsService { | |
| // MARK: - Properties - | |
| // The list of services added to this class as observers. | |
| internal private(set) var services = [AnalyticsService]() | |
| // MARK: - Singleton - | |
| static let instance = AnalyticsManager() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @UIApplicationMain | |
| class AppDelegate: UIResponder, UIApplicationDelegate { | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
| let cleverTapAnalyticsService: CleverTapAnalyticsService = CleverTapAnalyticsService() | |
| let mixpanelAnalyticsService: MixpanelAnalyticsService = MixpanelAnalyticsService() | |
| AnalyticsManager.instance.add(service: cleverTapAnalyticsService) | |
| AnalyticsManager.instance.add(service: mixpanelAnalyticsService) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| extension Array { | |
| func grouped<T>(by criteria: (Element) -> T) -> [T: [Element]] { | |
| var groups = [T: [Element]]() | |
| for element in self { | |
| let key = criteria(element) | |
| if groups.keys.contains(key) == false { | |
| groups[key] = [Element]() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import PluggableApplicationDelegate | |
| final class LoggerApplicationService: NSObject, ApplicationService { | |
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { | |
| print("It has started!") | |
| return true | |
| } | |
| func applicationDidEnterBackground(_ application: UIApplication) { |