Skip to content

Commit

Permalink
Updated app configuration and added answers custom events
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrollin committed Oct 17, 2016
1 parent ae1e8c3 commit 841ddf9
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
11 changes: 7 additions & 4 deletions Drivecast.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@
49FC9A1D1BCFB5D4006FA40E = {
CreatedOnToolsVersion = 7.0.1;
DevelopmentTeam = 7S5AAN8833;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
Expand Down Expand Up @@ -990,9 +991,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 7S5AAN8833;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand All @@ -1011,9 +1012,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 7S5AAN8833;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down Expand Up @@ -1136,9 +1138,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 7S5AAN8833;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down Expand Up @@ -1230,9 +1232,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 7S5AAN8833;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
Expand Down
8 changes: 6 additions & 2 deletions Drivecast/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1.1</string>
<string>1.1.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>27</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down Expand Up @@ -51,6 +51,10 @@
</dict>
</dict>
</dict>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Bluetooth is needed to connect to your Safecast Drive device to record measurements.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>???</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
Expand Down
18 changes: 9 additions & 9 deletions Drivecast/Libraries/SDCBluetoothManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ extension SDCBluetoothManager {

// Starts scanning for remote peripherals
func startScanning() throws {
guard let centralManager = self.centralManager
where self.state == .Ready else {
guard let centralManager = self.centralManager where
self.state == .Ready else {
throw SDCBluetoothManager.Error.InvalidState(self.state)
}

Expand All @@ -131,8 +131,8 @@ extension SDCBluetoothManager {

// Stops scanning for remote peripherals
func stopScanning() throws {
guard let centralManager = self.centralManager
where self.state == .Ready else {
guard let centralManager = self.centralManager where
self.state == .Ready else {
throw SDCBluetoothManager.Error.InvalidState(self.state)
}

Expand All @@ -141,8 +141,8 @@ extension SDCBluetoothManager {

// Connects a discovered peripheral
func connect(peripheral: SDCBluetoothRemotePeripheral) throws {
guard let centralManager = self.centralManager
where self.state == .Ready else {
guard let centralManager = self.centralManager where
self.state == .Ready else {
throw SDCBluetoothManager.Error.InvalidState(self.state)
}

Expand All @@ -153,8 +153,8 @@ extension SDCBluetoothManager {

// Disconnects a connecting or connected peripheral
func disconnect(peripheral: SDCBluetoothRemotePeripheral) throws {
guard let centralManager = self.centralManager
where self.state == .Connecting || self.state == .Connected else {
guard let centralManager = self.centralManager where
self.state == .Connecting || self.state == .Connected else {
throw SDCBluetoothManager.Error.InvalidState(self.state)
}

Expand Down Expand Up @@ -209,4 +209,4 @@ extension SDCBluetoothManager: CBCentralManagerDelegate {

self.delegate?.remotePeripheralDidDisconnect(self, peripheral: disconnectedPeripheral)
}
}
}
13 changes: 12 additions & 1 deletion Drivecast/ViewModels/SDCDashboardViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import ReactiveCocoa
import KVNProgress
import RealmSwift
import Crashlytics

class SDCDashboardViewModel {

Expand Down Expand Up @@ -65,6 +66,10 @@ extension SDCDashboardViewModel {
switch result {
case .Success(let user):
dlog(user)

Crashlytics.sharedInstance().setUserEmail(user.email)
Crashlytics.sharedInstance().setUserIdentifier(String(user.id))
Crashlytics.sharedInstance().setUserName(user.name)

self.updateUser()
case .Failure(let error):
Expand Down Expand Up @@ -144,6 +149,9 @@ extension SDCDashboardViewModel {

self.updateImportLogs()

Answers.logCustomEventWithName("ImportSubmitted",
customAttributes: [:])

KVNProgress.showSuccess()
case .Failure(let error):
dlog(error)
Expand Down Expand Up @@ -185,6 +193,9 @@ extension SDCDashboardViewModel {

self.updateImportLogs()

Answers.logCustomEventWithName("MetadataEdited",
customAttributes: [:])

KVNProgress.showSuccess()
case .Failure(let error):
dlog(error)
Expand All @@ -193,4 +204,4 @@ extension SDCDashboardViewModel {
}
}
}
}
}
4 changes: 4 additions & 0 deletions Drivecast/ViewModels/SDCRecordViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import CoreBluetooth
import ReactiveCocoa
import Crashlytics
import enum Result.NoError

class SDCRecordViewModel: NSObject {
Expand Down Expand Up @@ -72,6 +73,9 @@ class SDCRecordViewModel: NSObject {
self.printOnConsole("started recording", type: .Emphasys)
self.actionButtonString.value = "pause recording".uppercaseString
self.timer = self.resumeTimer()

Answers.logCustomEventWithName("RecordingSessionStarted",
customAttributes: [:])

} else {
self.printOnConsole("stopped recording", type: .Emphasys)
Expand Down
7 changes: 6 additions & 1 deletion Drivecast/ViewModels/SDCSignInViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation
import ReactiveCocoa
import Crashlytics

struct SDCSignInViewModel {

Expand Down Expand Up @@ -53,6 +54,10 @@ struct SDCSignInViewModel {
case .Success(let user):
dlog(user)

Answers.logLoginWithMethod("API",
success: true,
customAttributes: [:])

SDCUser.authenticatedUser = user
self.userIsAuthenticated.value = true
case .Failure(let error):
Expand Down Expand Up @@ -116,4 +121,4 @@ struct SDCSignInViewModel {
return self.validateCredentials(email, password: password)
}
}
}
}
9 changes: 8 additions & 1 deletion Drivecast/ViewModels/SDCUploadViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ReactiveCocoa
import RealmSwift
import BEMSimpleLineGraph
import KVNProgress
import Crashlytics
import enum Result.NoError

class SDCUploadViewModel: NSObject {
Expand Down Expand Up @@ -60,6 +61,9 @@ extension SDCUploadViewModel {
realm.delete(measurements)
}

Answers.logCustomEventWithName("MeasurementsDiscarded",
customAttributes: [:])

// Update measurements to dismiss the upload screen and display the record button
updateMeasurementData()
}
Expand Down Expand Up @@ -118,6 +122,9 @@ extension SDCUploadViewModel {

self.discardAllMeasurements()

Answers.logCustomEventWithName("MeasurementsDiscarded",
customAttributes: [:])

UIApplication.showTab(SDCConfiguration.UI.TabBarMenu.Dashboard)

KVNProgress.showSuccess()
Expand Down Expand Up @@ -191,4 +198,4 @@ extension SDCUploadViewModel: BEMSimpleLineGraphDataSource {

return CGFloat(measurementForIndex(index)?.cpm ?? 0)
}
}
}

0 comments on commit 841ddf9

Please sign in to comment.