mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 06:47:15 +00:00
Refactored uuid into preferences
This commit is contained in:
1 parent
81827aaf9b
commit
a62478400e
6 files changed
+22
-48
No files matched your search
@@ -11,7 +11,6 @@
|
|||||||
7F03FD3E19FA44CD00FA1327 /* APIManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F03FD3D19FA44CD00FA1327 /* APIManager.swift */; };
|
7F03FD3E19FA44CD00FA1327 /* APIManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F03FD3D19FA44CD00FA1327 /* APIManager.swift */; };
|
||||||
7F0658FD19F7D6700077FF95 /* ScanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0658FC19F7D6700077FF95 /* ScanViewController.swift */; };
|
7F0658FD19F7D6700077FF95 /* ScanViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0658FC19F7D6700077FF95 /* ScanViewController.swift */; };
|
||||||
7F0658FF19F7EE910077FF95 /* CheckInData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0658FE19F7EE910077FF95 /* CheckInData.swift */; };
|
7F0658FF19F7EE910077FF95 /* CheckInData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F0658FE19F7EE910077FF95 /* CheckInData.swift */; };
|
||||||
7F06590419F8094C0077FF95 /* DeviceUDIDManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F06590319F8094C0077FF95 /* DeviceUDIDManager.swift */; };
|
|
||||||
7F14A10A1A13B9A6001C1ECB /* _abkhazia.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F14A0041A13B9A6001C1ECB /* _abkhazia.png */; };
|
7F14A10A1A13B9A6001C1ECB /* _abkhazia.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F14A0041A13B9A6001C1ECB /* _abkhazia.png */; };
|
||||||
7F14A10B1A13B9A6001C1ECB /* _basque-country.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F14A0051A13B9A6001C1ECB /* _basque-country.png */; };
|
7F14A10B1A13B9A6001C1ECB /* _basque-country.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F14A0051A13B9A6001C1ECB /* _basque-country.png */; };
|
||||||
7F14A10C1A13B9A6001C1ECB /* _british-antarctic-territory.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F14A0061A13B9A6001C1ECB /* _british-antarctic-territory.png */; };
|
7F14A10C1A13B9A6001C1ECB /* _british-antarctic-territory.png in Resources */ = {isa = PBXBuildFile; fileRef = 7F14A0061A13B9A6001C1ECB /* _british-antarctic-territory.png */; };
|
||||||
@@ -393,7 +392,6 @@
|
|||||||
7F03FD3F19FA4D7400FA1327 /* bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = "<group>"; };
|
7F03FD3F19FA4D7400FA1327 /* bridge.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = "<group>"; };
|
||||||
7F0658FC19F7D6700077FF95 /* ScanViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ScanViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
7F0658FC19F7D6700077FF95 /* ScanViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ScanViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||||
7F0658FE19F7EE910077FF95 /* CheckInData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CheckInData.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
7F0658FE19F7EE910077FF95 /* CheckInData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CheckInData.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
|
||||||
7F06590319F8094C0077FF95 /* DeviceUDIDManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceUDIDManager.swift; sourceTree = "<group>"; };
|
|
||||||
7F14A0041A13B9A6001C1ECB /* _abkhazia.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = _abkhazia.png; sourceTree = "<group>"; };
|
7F14A0041A13B9A6001C1ECB /* _abkhazia.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = _abkhazia.png; sourceTree = "<group>"; };
|
||||||
7F14A0051A13B9A6001C1ECB /* _basque-country.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "_basque-country.png"; sourceTree = "<group>"; };
|
7F14A0051A13B9A6001C1ECB /* _basque-country.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "_basque-country.png"; sourceTree = "<group>"; };
|
||||||
7F14A0061A13B9A6001C1ECB /* _british-antarctic-territory.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "_british-antarctic-territory.png"; sourceTree = "<group>"; };
|
7F14A0061A13B9A6001C1ECB /* _british-antarctic-territory.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "_british-antarctic-territory.png"; sourceTree = "<group>"; };
|
||||||
@@ -791,7 +789,6 @@
|
|||||||
7F2C605919F160E400C32D93 /* LocationManager.swift */,
|
7F2C605919F160E400C32D93 /* LocationManager.swift */,
|
||||||
7FA6551919F6661900A1B92D /* DataManager.swift */,
|
7FA6551919F6661900A1B92D /* DataManager.swift */,
|
||||||
7F03FD3D19FA44CD00FA1327 /* APIManager.swift */,
|
7F03FD3D19FA44CD00FA1327 /* APIManager.swift */,
|
||||||
7F06590319F8094C0077FF95 /* DeviceUDIDManager.swift */,
|
|
||||||
7F1B66F81A0CDCF600904A41 /* BatteryManager.swift */,
|
7F1B66F81A0CDCF600904A41 /* BatteryManager.swift */,
|
||||||
7F3AA7C71A1CD7D700F8861F /* SendGPSFixController.swift */,
|
7F3AA7C71A1CD7D700F8861F /* SendGPSFixController.swift */,
|
||||||
C852BA961CF2302D0093B0C5 /* CameraController.swift */,
|
C852BA961CF2302D0093B0C5 /* CameraController.swift */,
|
||||||
@@ -1836,7 +1833,6 @@
|
|||||||
7F99DE3C1A126554009B3619 /* RegattaViewController.swift in Sources */,
|
7F99DE3C1A126554009B3619 /* RegattaViewController.swift in Sources */,
|
||||||
7F8CC2081A10D47A00C56D7F /* SettingsViewController.swift in Sources */,
|
7F8CC2081A10D47A00C56D7F /* SettingsViewController.swift in Sources */,
|
||||||
7F4EEDBA1A6D2BAC0026F711 /* CheckIn.swift in Sources */,
|
7F4EEDBA1A6D2BAC0026F711 /* CheckIn.swift in Sources */,
|
||||||
7F06590419F8094C0077FF95 /* DeviceUDIDManager.swift in Sources */,
|
|
||||||
7F3AA7C81A1CD7D700F8861F /* SendGPSFixController.swift in Sources */,
|
7F3AA7C81A1CD7D700F8861F /* SendGPSFixController.swift in Sources */,
|
||||||
7FCDB6641A1636610075D7D9 /* LeaderBoard.swift in Sources */,
|
7FCDB6641A1636610075D7D9 /* LeaderBoard.swift in Sources */,
|
||||||
C852BAAD1CF757950093B0C5 /* CheckInViewController.swift in Sources */,
|
C852BAAD1CF757950093B0C5 /* CheckInViewController.swift in Sources */,
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class CheckInController : NSObject {
|
|||||||
SVProgressHUD.show()
|
SVProgressHUD.show()
|
||||||
checkInRequestManager.checkIn(checkInData.dictionaryLeaderboardName(),
|
checkInRequestManager.checkIn(checkInData.dictionaryLeaderboardName(),
|
||||||
competitorID: checkInData!.dictionaryCompetitorId(),
|
competitorID: checkInData!.dictionaryCompetitorId(),
|
||||||
deviceUUID: DeviceUDIDManager.UDID,
|
deviceUUID: Preferences.uuid(),
|
||||||
pushDeviceID: "",
|
pushDeviceID: "",
|
||||||
fromMillis: millisSince1970(),
|
fromMillis: millisSince1970(),
|
||||||
success: { (operation, responseObject) -> Void in self.checkInOnServerSucceed() },
|
success: { (operation, responseObject) -> Void in self.checkInOnServerSucceed() },
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
//
|
|
||||||
// DeviceUDIDManager.swift
|
|
||||||
// SAPTracker
|
|
||||||
//
|
|
||||||
// Created by computing on 22/10/14.
|
|
||||||
// Copyright (c) 2014 com.sap.sailing. All rights reserved.
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
struct DeviceUDIDManager {
|
|
||||||
|
|
||||||
struct Keys {
|
|
||||||
static let UDID = "udid"
|
|
||||||
}
|
|
||||||
|
|
||||||
private static let preferences = NSUserDefaults.standardUserDefaults()
|
|
||||||
private static var staticUDID: String?
|
|
||||||
|
|
||||||
static var UDID: String {
|
|
||||||
get {
|
|
||||||
if (staticUDID == nil) {
|
|
||||||
if preferences.objectForKey(Keys.UDID) == nil {
|
|
||||||
staticUDID = NSUUID().UUIDString.lowercaseString
|
|
||||||
preferences.setObject(staticUDID, forKey: Keys.UDID)
|
|
||||||
preferences.synchronize()
|
|
||||||
} else {
|
|
||||||
staticUDID = preferences.objectForKey(Keys.UDID) as? String
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return staticUDID!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,7 @@ class Preferences: NSObject {
|
|||||||
struct PreferenceKey {
|
struct PreferenceKey {
|
||||||
static let lastCheckInURLString = "lastCheckInURLString"
|
static let lastCheckInURLString = "lastCheckInURLString"
|
||||||
static let acceptedTerms = "acceptedTerms"
|
static let acceptedTerms = "acceptedTerms"
|
||||||
|
static let uuid = "udid"
|
||||||
}
|
}
|
||||||
|
|
||||||
private static let preferences = NSUserDefaults.standardUserDefaults()
|
private static let preferences = NSUserDefaults.standardUserDefaults()
|
||||||
@@ -20,23 +21,35 @@ class Preferences: NSObject {
|
|||||||
// MARK: - LastCheckInData
|
// MARK: - LastCheckInData
|
||||||
|
|
||||||
class func setLastCheckInURLString(urlString: String?) {
|
class func setLastCheckInURLString(urlString: String?) {
|
||||||
preferences.setObject(urlString, forKey: PreferenceKey.lastCheckInURLString)
|
self.preferences.setObject(urlString, forKey: PreferenceKey.lastCheckInURLString)
|
||||||
preferences.synchronize()
|
self.preferences.synchronize()
|
||||||
}
|
}
|
||||||
|
|
||||||
class func lastCheckInURLString() -> String? {
|
class func lastCheckInURLString() -> String? {
|
||||||
return preferences.stringForKey(PreferenceKey.lastCheckInURLString)
|
return self.preferences.stringForKey(PreferenceKey.lastCheckInURLString)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - AcceptedTerms
|
// MARK: - AcceptedTerms
|
||||||
|
|
||||||
class func acceptedTerms() -> Bool {
|
class func acceptedTerms() -> Bool {
|
||||||
return preferences.boolForKey(PreferenceKey.acceptedTerms)
|
return self.preferences.boolForKey(PreferenceKey.acceptedTerms)
|
||||||
}
|
}
|
||||||
|
|
||||||
class func setAcceptedTerms(value: Bool) {
|
class func setAcceptedTerms(value: Bool) {
|
||||||
preferences.setBool(value, forKey:PreferenceKey.acceptedTerms)
|
self.preferences.setBool(value, forKey:PreferenceKey.acceptedTerms)
|
||||||
preferences.synchronize()
|
self.preferences.synchronize()
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - UUID
|
||||||
|
|
||||||
|
private static var UUID: String?
|
||||||
|
class func uuid() -> String {
|
||||||
|
if UUID == nil {
|
||||||
|
UUID = self.preferences.stringForKey(PreferenceKey.uuid) ?? NSUUID().UUIDString.lowercaseString
|
||||||
|
preferences.setObject(UUID, forKey: PreferenceKey.uuid)
|
||||||
|
preferences.synchronize()
|
||||||
|
}
|
||||||
|
return UUID!
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -298,7 +298,7 @@ class RegattaViewController : UIViewController, UIActionSheetDelegate, UINavigat
|
|||||||
let toMillis = Int64(now.timeIntervalSince1970 * 1000)
|
let toMillis = Int64(now.timeIntervalSince1970 * 1000)
|
||||||
APIManager.sharedManager.checkOut(DataManager.sharedManager.selectedCheckIn!.leaderBoardName,
|
APIManager.sharedManager.checkOut(DataManager.sharedManager.selectedCheckIn!.leaderBoardName,
|
||||||
competitorId: DataManager.sharedManager.selectedCheckIn!.competitorId,
|
competitorId: DataManager.sharedManager.selectedCheckIn!.competitorId,
|
||||||
deviceUuid: DeviceUDIDManager.UDID,
|
deviceUuid: Preferences.uuid(),
|
||||||
toMillis: toMillis,
|
toMillis: toMillis,
|
||||||
success: { (operation, competitorResponseObject) -> Void in
|
success: { (operation, competitorResponseObject) -> Void in
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class SendGPSFixController: NSObject {
|
|||||||
func sendGPSFixes(serverUrl: String, gpsFixes:[GPSFix]) {
|
func sendGPSFixes(serverUrl: String, gpsFixes:[GPSFix]) {
|
||||||
APIManager.sharedManager.initManager(serverUrl)
|
APIManager.sharedManager.initManager(serverUrl)
|
||||||
if APIManager.sharedManager.networkAvailable {
|
if APIManager.sharedManager.networkAvailable {
|
||||||
APIManager.sharedManager.postGPSFixes(DeviceUDIDManager.UDID, gpsFixes: gpsFixes,
|
APIManager.sharedManager.postGPSFixes(Preferences.uuid(), gpsFixes: gpsFixes,
|
||||||
success: { (operation, competitorResponseObject) -> Void in
|
success: { (operation, competitorResponseObject) -> Void in
|
||||||
print("sent GPS fixes")
|
print("sent GPS fixes")
|
||||||
for gpsFix in gpsFixes {
|
for gpsFix in gpsFixes {
|
||||||
|
|||||||
Reference in new issue
Block a user