Skip to content

Instantly share code, notes, and snippets.

View rldaulton's full-sized avatar
®️
Makin' Apps and Laughs

Ryan Daulton rldaulton

®️
Makin' Apps and Laughs
View GitHub Profile
@rldaulton
rldaulton / check-universal.swift
Created February 28, 2019 19:59
You should always check if a link is univeral, before opening it in any browser session of SFSafariView
let url = URL(string: "https://youtu.be/5IVsLLlRNXc")!
UIApplication.shared.open(url, options: [.universalLinksOnly: true]) { (success) in
if !success {
// not a universal link or app not installed
let vc = SFSafariViewController(url: url)
self.present(vc, animated: true)
}
}
@rldaulton
rldaulton / LabelMould.swift
Created February 6, 2019 00:17
An example of a mould, using a UILabel
// Mould
extension UILabel {
class var heading: UILabel {
let mould: UILabel = .init()
mould.font = .systemFont(ofSize: 18.0)
mould.textColor = .black
mould.translatesAutoresizingMaskIntoConstraints = false
return mould
}
@rldaulton
rldaulton / secure.swift
Last active October 2, 2018 17:29
Saving Sensitive Information to iOS Keychain
func testPaswordRetrive() {
let password = "123456"
let account = "User"
keyChainService.save(password, for: account)
XCTAssertEqual(keyChainService.retrivePassword(for: account), password)
}
//...
class KeychainService {
func save(_ password: String, for account: String) {
@rldaulton
rldaulton / NetworkManager.swift
Created September 25, 2017 14:46
Project Management with Global Enums
enum Environment {
case development
case staging
case production
}
let environment: Environment = .development
switch environment {
case .development:
@rldaulton
rldaulton / NetworkManager.swift
Created August 16, 2017 15:57
A simple Swift network management file
//
// NetworkManager.swift
//
// Created by Ryan Daulton on 8/15/17.
// Copyright © 2017 Ryan Daulton. All rights reserved.
//
import Foundation
import Alamofire
import SwiftyJSON
@rldaulton
rldaulton / SpotifyAuthCodeFlow_RefreshToken.js
Last active February 10, 2021 00:15
Spotify Authorization Code Flow [Android helper] using Google Cloud Functions
/*
* A Spotify Authorization Code Flow, used specifically for Android.
* I have been trying to do a refresh token in an android client, but I
* notice that when a user logs in using Spotify's SDK, they do not
* receive a refresh_token. I do not want my users to have to log in every
* time they use the app.
*
* After finding this issue:
*
* https://github.com/spotify/android-sdk/issues/259