This file contains 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
/// custom unique identifier | |
/// @see https://www.firebase.com/blog/2015-02-11-firebase-unique-identifiers.html | |
private let ASC_CHARS = Array("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz") | |
private let DESC_CHARS = ASC_CHARS.reverse() | |
private var lastPushTime: UInt64 = 0 | |
private var lastRandChars = Array<Int>(count: 12, repeatedValue: 0) | |
func generatePushID(ascending: Bool = true) -> String { | |
let PUSH_CHARS = ascending ? ASC_CHARS: DESC_CHARS | |
var timeStampChars = Array<Character>(count: 8, repeatedValue: PUSH_CHARS.first!) |