diff --git a/Steps4Impact.xcodeproj/project.pbxproj b/Steps4Impact.xcodeproj/project.pbxproj index 832e6d0e..f9ce5e70 100644 --- a/Steps4Impact.xcodeproj/project.pbxproj +++ b/Steps4Impact.xcodeproj/project.pbxproj @@ -320,6 +320,7 @@ 3AAA329F23655CB5002B7479 /* LoginButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginButton.swift; sourceTree = ""; }; 644A965BB27AB6174A19603E /* Pods_Steps4ImpactTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Steps4ImpactTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7D885FB78222CE09537F0C6A /* Pods-steps4impact.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-steps4impact.debug.xcconfig"; path = "Target Support Files/Pods-steps4impact/Pods-steps4impact.debug.xcconfig"; sourceTree = ""; }; + A51064892895F99C001467A2 /* Steps4ImpactDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Steps4ImpactDebug.entitlements; sourceTree = ""; }; A5123F1E2381B51E00C3E9DE /* JourneyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JourneyViewController.swift; sourceTree = ""; }; A5123F212381B60B00C3E9DE /* MilestoneCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MilestoneCell.swift; sourceTree = ""; }; A5123F232381B63300C3E9DE /* JourneyDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JourneyDataSource.swift; sourceTree = ""; }; @@ -702,6 +703,7 @@ 269E34C81E765828000726C2 /* Steps4Impact */ = { isa = PBXGroup; children = ( + A51064892895F99C001467A2 /* Steps4ImpactDebug.entitlements */, A52E332B246768DA008FAF71 /* PushNotifications */, A5123F1D2381B4F700C3E9DE /* Journey */, A57A29FA236E404C002AA380 /* BadgesV2 */, @@ -791,13 +793,13 @@ sourceTree = ""; }; A52E332B246768DA008FAF71 /* PushNotifications */ = { - isa = PBXGroup; - children = ( - A52E332C24676929008FAF71 /* PushNotificationManager.swift */, - ); - path = PushNotifications; - sourceTree = ""; - }; + isa = PBXGroup; + children = ( + A52E332C24676929008FAF71 /* PushNotificationManager.swift */, + ); + path = PushNotifications; + sourceTree = ""; + }; A550395E23823FE500788157 /* Cells */ = { isa = PBXGroup; children = ( @@ -1009,7 +1011,7 @@ }; 269E34C51E765828000726C2 = { CreatedOnToolsVersion = 8.2.1; - DevelopmentTeam = 6SQ8F32998; + DevelopmentTeam = 77MLE67A45; LastSwiftMigration = 1020; ProvisioningStyle = Automatic; SystemCapabilities = { @@ -1609,15 +1611,15 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_ENTITLEMENTS = "Steps4Impact/Supporting Files/Steps4Impact.entitlements"; + CODE_SIGN_ENTITLEMENTS = Steps4Impact/Steps4ImpactDebug.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 278; - DEVELOPMENT_TEAM = 6SQ8F32998; + CURRENT_PROJECT_VERSION = 280; + DEVELOPMENT_TEAM = 77MLE67A45; INFOPLIST_FILE = "Steps4Impact/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.0.5; - PRODUCT_BUNDLE_IDENTIFIER = com.akf.WalkingChallenge; + PRODUCT_BUNDLE_IDENTIFIER = com.akf.WalkingChallenge.aalim; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -1636,7 +1638,7 @@ CODE_SIGN_ENTITLEMENTS = "Steps4Impact/Supporting Files/Steps4Impact.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 278; + CURRENT_PROJECT_VERSION = 280; DEVELOPMENT_TEAM = 6SQ8F32998; INFOPLIST_FILE = "Steps4Impact/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff --git a/Steps4Impact/App/AppConfig.swift b/Steps4Impact/App/AppConfig.swift index 5d35d4cb..898a399f 100644 --- a/Steps4Impact/App/AppConfig.swift +++ b/Steps4Impact/App/AppConfig.swift @@ -31,27 +31,29 @@ import Foundation struct AppConfig { static var server: URLComponents { - if UserInfo.isStaging { - return URLComponents(string: "https://staging.step4change.org")! // swiftlint:disable:this force_unwrapping - } else { - #if DEBUG - return URLComponents(string: "https://dev.step4change.org")! // swiftlint:disable:this force_unwrapping - #else - return URLComponents(string: "http://step4change.org")! // swiftlint:disable:this force_unwrapping - #endif - } +// if UserInfo.isStaging { +// return URLComponents(string: "https://staging.steps4impact.org")! // swiftlint:disable:this force_unwrapping +// } else { +// #if DEBUG +// return URLComponents(string: "https://steps4impact-dev.azurewebsites.net")! // swiftlint:disable:this force_unwrapping +// #else +// return URLComponents(string: "https://production.steps4impact.org")! // swiftlint:disable:this force_unwrapping +// #endif +// } + return URLComponents(string: "https://steps4impact-test.theismailiusa.org")! } static var serverPassword: String { - if UserInfo.isStaging { - return AppSecrets.stagingPassword - } else { - #if DEBUG - return AppSecrets.devPassword - #else - return AppSecrets.prodPassword - #endif - } +// if UserInfo.isStaging { +// return AppSecrets.stagingPassword +// } else { +// #if DEBUG +// return AppSecrets.devPassword +// #else +// return AppSecrets.prodPassword +// #endif +// } + return "dGVzdDp0ZXN0" } static let appCenterSecret = "9ca54e4e-20df-425a-bfe6-b72d0daad2da" // TODO: Move this to CI env diff --git a/Steps4Impact/App/Cache.swift b/Steps4Impact/App/Cache.swift index fd7ad5e4..24e1f3a2 100644 --- a/Steps4Impact/App/Cache.swift +++ b/Steps4Impact/App/Cache.swift @@ -55,6 +55,15 @@ class Cache { } } + func fetchParticipant(fbid: FirebaseID) { + AKFCausesService.getParticipant(fbid: fbid) { [weak self] (result) in + guard result.isSuccess, let participant = Participant(json: result.response) else { + return + } + self?.update(participant: participant) + } + } + let socialDisplayNamesRelay = BehaviorRelay<[FirebaseID: SocialDisplayName]>(value: [:]) private var socialDisplayNames = [FirebaseID: SocialDisplayName]() func update(fbid: FirebaseID, name: SocialDisplayName) { @@ -84,5 +93,8 @@ class Cache { } let participantRelay = BehaviorRelay(value: nil) + func update(participant: Participant) { + participantRelay.accept(participant) + } let currentEventRelay = BehaviorRelay(value: nil) } diff --git a/Steps4Impact/BadgesV2/Cells/BadgeCell.swift b/Steps4Impact/BadgesV2/Cells/BadgeCell.swift index be0d9553..f9ae392b 100644 --- a/Steps4Impact/BadgesV2/Cells/BadgeCell.swift +++ b/Steps4Impact/BadgesV2/Cells/BadgeCell.swift @@ -20,7 +20,7 @@ struct Badge: CellContext { var badgeType: BadgeType = .unknown } -protocol BadgeCellDelegate: class { +protocol BadgeCellDelegate: AnyObject { func badgeCellTapped() } diff --git a/Steps4Impact/Challenge/Cells/ChallengeTeamProgressCell.swift b/Steps4Impact/Challenge/Cells/ChallengeTeamProgressCell.swift index 66608f39..155b0037 100644 --- a/Steps4Impact/Challenge/Cells/ChallengeTeamProgressCell.swift +++ b/Steps4Impact/Challenge/Cells/ChallengeTeamProgressCell.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol ChallengeTeamProgressCellDelegate: class { +protocol ChallengeTeamProgressCellDelegate: AnyObject { func challengeTeamProgressDisclosureTapped() func challengeTeamProgressEditTapped() } diff --git a/Steps4Impact/Challenge/Cells/TeamNeededCell.swift b/Steps4Impact/Challenge/Cells/TeamNeededCell.swift index 3decc1bf..cf050aed 100644 --- a/Steps4Impact/Challenge/Cells/TeamNeededCell.swift +++ b/Steps4Impact/Challenge/Cells/TeamNeededCell.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol TeamNeededCellDelegate: class { +protocol TeamNeededCellDelegate: AnyObject { func teamNeededCellPrimaryTapped() func teamNeededCellSecondaryTapped() } diff --git a/Steps4Impact/CommonUI/Cells/DisclosureCell.swift b/Steps4Impact/CommonUI/Cells/DisclosureCell.swift index bb93811c..fb2bb78c 100644 --- a/Steps4Impact/CommonUI/Cells/DisclosureCell.swift +++ b/Steps4Impact/CommonUI/Cells/DisclosureCell.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol DisclosureCellDelegate: class { +protocol DisclosureCellDelegate: AnyObject { func disclosureCellTapped(context: Context?) } diff --git a/Steps4Impact/CommonUI/Cells/ImageButtonCell.swift b/Steps4Impact/CommonUI/Cells/ImageButtonCell.swift index 616073c0..64f7a929 100644 --- a/Steps4Impact/CommonUI/Cells/ImageButtonCell.swift +++ b/Steps4Impact/CommonUI/Cells/ImageButtonCell.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol ImageButtonCellDelegate: class { +protocol ImageButtonCellDelegate: AnyObject { func imageButtonCellTapped(context: Context?) } diff --git a/Steps4Impact/CommonUI/Views/CellDisclosureView.swift b/Steps4Impact/CommonUI/Views/CellDisclosureView.swift index 5d82e6fb..7c044afd 100644 --- a/Steps4Impact/CommonUI/Views/CellDisclosureView.swift +++ b/Steps4Impact/CommonUI/Views/CellDisclosureView.swift @@ -29,7 +29,7 @@ import UIKit -protocol CellDisclosureViewDelegate: class { +protocol CellDisclosureViewDelegate: AnyObject { func cellDisclosureTapped() } diff --git a/Steps4Impact/CommonUI/Views/CellImageButtonView.swift b/Steps4Impact/CommonUI/Views/CellImageButtonView.swift index 3e34200b..a2b7401e 100644 --- a/Steps4Impact/CommonUI/Views/CellImageButtonView.swift +++ b/Steps4Impact/CommonUI/Views/CellImageButtonView.swift @@ -29,7 +29,7 @@ import UIKit -protocol CellImageButtonViewDelegate: class { +protocol CellImageButtonViewDelegate: AnyObject { func cellImageButtonViewTapped() } diff --git a/Steps4Impact/CommonUI/Views/RadioButton.swift b/Steps4Impact/CommonUI/Views/RadioButton.swift index 9dc143d5..c503d0fa 100644 --- a/Steps4Impact/CommonUI/Views/RadioButton.swift +++ b/Steps4Impact/CommonUI/Views/RadioButton.swift @@ -29,7 +29,7 @@ import UIKit -protocol RadioButtonDelegate: class { +protocol RadioButtonDelegate: AnyObject { func radioButtonTapped(radioButton: RadioButton) } diff --git a/Steps4Impact/CommonUI/Views/SelectionButton.swift b/Steps4Impact/CommonUI/Views/SelectionButton.swift index 4cfe27ea..f63e0579 100644 --- a/Steps4Impact/CommonUI/Views/SelectionButton.swift +++ b/Steps4Impact/CommonUI/Views/SelectionButton.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol SelectionButtonDataSource: class { +protocol SelectionButtonDataSource: AnyObject { var items: [String] { get } var selection: Int? { get set } } @@ -102,7 +102,7 @@ extension SelectionButtonPopoverViewController: UIPopoverPresentationControllerD } } -protocol SelectionButtonDelegate: class { +protocol SelectionButtonDelegate: AnyObject { func present(_ viewControllerToPresent: UIViewController, animated flag: Bool, completion: (() -> Swift.Void)?) } diff --git a/Steps4Impact/DashboardV2/Cells/ConnectedActivityCardCell.swift b/Steps4Impact/DashboardV2/Cells/ConnectedActivityCardCell.swift index 682375f6..7fdb90ba 100644 --- a/Steps4Impact/DashboardV2/Cells/ConnectedActivityCardCell.swift +++ b/Steps4Impact/DashboardV2/Cells/ConnectedActivityCardCell.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol ConnectedActivityCellDelegate: class { +protocol ConnectedActivityCellDelegate: AnyObject { } struct ConnectedActivityCellContext: CellContext { diff --git a/Steps4Impact/DashboardV2/Cells/EmptyActivityCardCell.swift b/Steps4Impact/DashboardV2/Cells/EmptyActivityCardCell.swift index 2364db70..14b305d2 100644 --- a/Steps4Impact/DashboardV2/Cells/EmptyActivityCardCell.swift +++ b/Steps4Impact/DashboardV2/Cells/EmptyActivityCardCell.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol EmptyActivityCellDelegate: class { +protocol EmptyActivityCellDelegate: AnyObject { func emptyActivityCellConnectTapped() } diff --git a/Steps4Impact/DashboardV2/Cells/ProfileCardCell.swift b/Steps4Impact/DashboardV2/Cells/ProfileCardCell.swift index 78977bef..fb83793d 100644 --- a/Steps4Impact/DashboardV2/Cells/ProfileCardCell.swift +++ b/Steps4Impact/DashboardV2/Cells/ProfileCardCell.swift @@ -31,7 +31,7 @@ import UIKit import SnapKit import SDWebImage -protocol ProfileCardCellDelegate: class { +protocol ProfileCardCellDelegate: AnyObject { func profileDisclosureTapped() } diff --git a/Steps4Impact/DashboardV2/DashboardDataSource.swift b/Steps4Impact/DashboardV2/DashboardDataSource.swift index ec96b6ad..3188f472 100644 --- a/Steps4Impact/DashboardV2/DashboardDataSource.swift +++ b/Steps4Impact/DashboardV2/DashboardDataSource.swift @@ -68,11 +68,11 @@ class DashboardDataSource: TableViewDataSource { cache.participantRelay) update.subscribeOnNext { [weak self] (names, imageURLs, participant) in - guard let `self` = self else { return } - self.name = names["me"] ?? " " - self.imageURL = imageURLs["me"] - self.teamName = participant?.team?.name ?? " " - if let event = participant?.currentEvent { + guard let `self` = self, let participant = participant else { return } + self.name = names[participant.fbid] ?? " " + self.imageURL = imageURLs[participant.fbid] + self.teamName = participant.team?.name ?? " " + if let event = participant.currentEvent { self.eventName = event.name self.eventTimeline = DateInterval(start: event.teamFormationPhase.start, end: event.challengePhase.end) self.eventTimelineString = DataFormatters diff --git a/Steps4Impact/DashboardV2/Views/ActivityDateView.swift b/Steps4Impact/DashboardV2/Views/ActivityDateView.swift index 4df6fed0..f3983f20 100644 --- a/Steps4Impact/DashboardV2/Views/ActivityDateView.swift +++ b/Steps4Impact/DashboardV2/Views/ActivityDateView.swift @@ -29,7 +29,7 @@ import UIKit -protocol ActivityDateViewDelegate: class { +protocol ActivityDateViewDelegate: AnyObject { func activityDateViewLeftTapped() func activityDateViewRightTapped() } diff --git a/Steps4Impact/DashboardV2/Views/ActivityTimeView.swift b/Steps4Impact/DashboardV2/Views/ActivityTimeView.swift index 861a41a6..2088668d 100644 --- a/Steps4Impact/DashboardV2/Views/ActivityTimeView.swift +++ b/Steps4Impact/DashboardV2/Views/ActivityTimeView.swift @@ -29,7 +29,7 @@ import UIKit -protocol ActivityTimeViewDelegate: class { +protocol ActivityTimeViewDelegate: AnyObject { func activityTimeViewTapped(time: ActivityTime) } diff --git a/Steps4Impact/DashboardV2/Views/ActivityUnitView.swift b/Steps4Impact/DashboardV2/Views/ActivityUnitView.swift index 86d189a3..9036e362 100644 --- a/Steps4Impact/DashboardV2/Views/ActivityUnitView.swift +++ b/Steps4Impact/DashboardV2/Views/ActivityUnitView.swift @@ -29,7 +29,7 @@ import UIKit -protocol ActivityUnitViewDelegate: class { +protocol ActivityUnitViewDelegate: AnyObject { func activityUnitViewTapped(unit: ActivityUnit) } diff --git a/Steps4Impact/Journey/Cells/JourneyDetailCell.swift b/Steps4Impact/Journey/Cells/JourneyDetailCell.swift index 788326ec..f2e77374 100644 --- a/Steps4Impact/Journey/Cells/JourneyDetailCell.swift +++ b/Steps4Impact/Journey/Cells/JourneyDetailCell.swift @@ -29,7 +29,7 @@ import UIKit -protocol JourneyDetailDelegate: class { +protocol JourneyDetailDelegate: AnyObject { func didGetShareText(_ shareText: String) } diff --git a/Steps4Impact/Journey/Cells/MilestoneCell.swift b/Steps4Impact/Journey/Cells/MilestoneCell.swift index 776cfec4..7899cd73 100644 --- a/Steps4Impact/Journey/Cells/MilestoneCell.swift +++ b/Steps4Impact/Journey/Cells/MilestoneCell.swift @@ -8,7 +8,7 @@ import UIKit -protocol MilestoneNameButtonDelegate: class { +protocol MilestoneNameButtonDelegate: AnyObject { func milestoneNameButtonTapped(sequence: Int) } diff --git a/Steps4Impact/LoginV2/LoginV2ViewController.swift b/Steps4Impact/LoginV2/LoginV2ViewController.swift index 96693c34..bf075cf8 100644 --- a/Steps4Impact/LoginV2/LoginV2ViewController.swift +++ b/Steps4Impact/LoginV2/LoginV2ViewController.swift @@ -152,12 +152,27 @@ class LoginV2ViewController: ViewController { // AKF-WCBackend extension LoginV2ViewController { private func linkAKFBackend(fbid: String) { - AKFCausesService.createParticipant(fbid: fbid) { [weak self] (_) in + + let handler = { [weak self] in onMain { AppController.shared.login() } self?.addParticipantToDefaultEventIfNeeded(fbid: fbid) } + + AKFCausesService.getParticipant(fbid: fbid) { (result) in + if !result.isSuccess { + AKFCausesService.createParticipant(fbid: fbid) { [weak self] (result) in + guard result.isSuccess else { + self?.alert(message: "Sign In failed. Please try again") + return + } + handler() + } + } else { + handler() + } + } } private func addParticipantToDefaultEventIfNeeded(fbid: String) { diff --git a/Steps4Impact/Networking/AZSClient.swift b/Steps4Impact/Networking/AZSClient.swift index dced392f..a9d0f132 100644 --- a/Steps4Impact/Networking/AZSClient.swift +++ b/Steps4Impact/Networking/AZSClient.swift @@ -11,20 +11,24 @@ import AZSClient class AZSClient { - static let accKey = String(AppSecrets.azureAccKey.reversed()) - static let serverURL = "https://teamimages.blob.core.windows.net/" - static let containerName = "teamimages-dev" - static let accountName = "teamimages" +// static let accKey = String(AppSecrets.azureAccKey.reversed()) + static let accKey = "qoLL+0O+vKrleXiGMrT6JPHsQI9f0juFYJ+aRJ8KnUkCwGbbYhaLpPMFOhIyuVXBMaibBcd5O9C6+AStLRpkVA==" +// static let serverURL = "https://teamimages.blob.core.windows.net/" + static let serverURL = "https://steps4impact.blob.core.windows.net/" +// static let containerName = "teamimages-dev" + static let containerName = "teamimages" +// static let accountName = "teamimages" + static let accountName = "steps4impact" static let folderName: String = { - if UserInfo.isStaging { - return "staging/" - } else { - #if DEBUG - return "dev/" - #else +// if UserInfo.isStaging { +// return "staging/" +// } else { +// #if DEBUG +// return "dev/" +// #else return "" - #endif - } +// #endif +// } }() static let connectionString = "DefaultEndpointsProtocol=https;AccountName=\(AZSClient.accountName);AccountKey=\(AZSClient.accKey)" static func uploadImage(data imageData: Data, teamName: String, completion: @escaping (Error?, Bool) -> (Void)) { diff --git a/Steps4Impact/NotificationsV2/NotificationsPermissionView.swift b/Steps4Impact/NotificationsV2/NotificationsPermissionView.swift index 02d4ac79..bcc35e07 100644 --- a/Steps4Impact/NotificationsV2/NotificationsPermissionView.swift +++ b/Steps4Impact/NotificationsV2/NotificationsPermissionView.swift @@ -30,7 +30,7 @@ import Foundation import UIKit -protocol NotificationPermissionCellDelegate: class { +protocol NotificationPermissionCellDelegate: AnyObject { func turnOnNotifictions() func close() } diff --git a/Steps4Impact/Protocols/Cells.swift b/Steps4Impact/Protocols/Cells.swift index 05b2c5ce..fd1c4b1b 100644 --- a/Steps4Impact/Protocols/Cells.swift +++ b/Steps4Impact/Protocols/Cells.swift @@ -33,11 +33,11 @@ protocol CellContext: Context { var identifier: String { get } } -protocol ConfigurableCell: class { +protocol ConfigurableCell: AnyObject { func configure(context: CellContext) } -protocol ReusableCell: class { +protocol ReusableCell: AnyObject { static var identifier: String { get } } diff --git a/Steps4Impact/Protocols/Keyboardable.swift b/Steps4Impact/Protocols/Keyboardable.swift index e32de7e9..461711f7 100644 --- a/Steps4Impact/Protocols/Keyboardable.swift +++ b/Steps4Impact/Protocols/Keyboardable.swift @@ -30,7 +30,7 @@ import UIKit import SnapKit -protocol Keyboardable: class { +protocol Keyboardable: AnyObject { func addKeyboardNotifications() func removeKeyboardNotifications() func keyboardChanged(notification: Foundation.Notification) diff --git a/Steps4Impact/Settings/Cells/AppInfoCell.swift b/Steps4Impact/Settings/Cells/AppInfoCell.swift index f9dac6a8..5f412328 100644 --- a/Steps4Impact/Settings/Cells/AppInfoCell.swift +++ b/Steps4Impact/Settings/Cells/AppInfoCell.swift @@ -36,7 +36,7 @@ struct AppInfoCellContext: CellContext { let body: String } -protocol AppInfoCellDelegate: class { +protocol AppInfoCellDelegate: AnyObject { func appInfoCellToggleStaging() } diff --git a/Steps4Impact/Settings/Cells/ConnectSourceCell.swift b/Steps4Impact/Settings/Cells/ConnectSourceCell.swift index afe91520..55b28dd7 100644 --- a/Steps4Impact/Settings/Cells/ConnectSourceCell.swift +++ b/Steps4Impact/Settings/Cells/ConnectSourceCell.swift @@ -29,7 +29,7 @@ import UIKit -protocol ConnectSourceCellDelegate: class { +protocol ConnectSourceCellDelegate: AnyObject { func updateSource(context: Context?) } diff --git a/Steps4Impact/Settings/Cells/SettingsActionCell.swift b/Steps4Impact/Settings/Cells/SettingsActionCell.swift index 97e892a4..2e920746 100644 --- a/Steps4Impact/Settings/Cells/SettingsActionCell.swift +++ b/Steps4Impact/Settings/Cells/SettingsActionCell.swift @@ -29,7 +29,7 @@ import UIKit -protocol SettingsActionCellDelegate: class { +protocol SettingsActionCellDelegate: AnyObject { func settingsActionCellTapped(context: Context?, button: UIButton) } diff --git a/Steps4Impact/Settings/Cells/SettingsSwitchCell.swift b/Steps4Impact/Settings/Cells/SettingsSwitchCell.swift index 81208302..9db72c83 100644 --- a/Steps4Impact/Settings/Cells/SettingsSwitchCell.swift +++ b/Steps4Impact/Settings/Cells/SettingsSwitchCell.swift @@ -29,7 +29,7 @@ import UIKit -protocol SettingsSwitchCellDelegate: class { +protocol SettingsSwitchCellDelegate: AnyObject { func settingsSwitchToggled(toggled: Bool, context: Context?) } diff --git a/Steps4Impact/Settings/Cells/TeamSettingsHeaderCell.swift b/Steps4Impact/Settings/Cells/TeamSettingsHeaderCell.swift index da8d832d..c74a224e 100644 --- a/Steps4Impact/Settings/Cells/TeamSettingsHeaderCell.swift +++ b/Steps4Impact/Settings/Cells/TeamSettingsHeaderCell.swift @@ -36,7 +36,7 @@ struct TeamSettingsHeaderCellContext: CellContext { let isLead: Bool } -protocol TeamSettingsHeaderCellDelegate: class { +protocol TeamSettingsHeaderCellDelegate: AnyObject { func editImageButtonPressed(cell: TeamSettingsHeaderCell) } diff --git a/Steps4Impact/Settings/Cells/TeamSettingsMemberCell.swift b/Steps4Impact/Settings/Cells/TeamSettingsMemberCell.swift index acfad6b0..de1af80d 100644 --- a/Steps4Impact/Settings/Cells/TeamSettingsMemberCell.swift +++ b/Steps4Impact/Settings/Cells/TeamSettingsMemberCell.swift @@ -57,7 +57,7 @@ struct TeamSettingsMemberCellContext: CellContext { } } -protocol TeamSettingsMemberCellDelegate: class { +protocol TeamSettingsMemberCellDelegate: AnyObject { func removeTapped(context: Context?, button: UIButton) } diff --git a/Steps4Impact/Settings/ConnectSourceViewController.swift b/Steps4Impact/Settings/ConnectSourceViewController.swift index 4029917d..30789044 100644 --- a/Steps4Impact/Settings/ConnectSourceViewController.swift +++ b/Steps4Impact/Settings/ConnectSourceViewController.swift @@ -118,21 +118,19 @@ extension ConnectSourceViewController: ConnectSourceCellDelegate { case .healthkit: // Just to ask for permission if HKHealthStore.isHealthDataAvailable() { - let typesToRead: Set = [ConnectSourceViewController.steps, ConnectSourceViewController.distance] + let authorizationStatus = HKHealthStore().authorizationStatus(for: .workoutType()) - HKHealthStore().getRequestStatusForAuthorization(toShare: [], read: typesToRead) { [weak self] (status, error) in - guard let `self` = self else { return } - - switch status { - case .unknown: - UserInfo.pedometerSource = nil + switch authorizationStatus { + case .notDetermined: + self.requestHealthKitAccess() + case .sharingDenied: + onMain { self.requestHealthKitUpdate() - case .shouldRequest: - self.requestHealthKitAccess() - case .unnecessary: - UserInfo.pedometerSource = .healthKit - @unknown default: - UserInfo.pedometerSource = nil + } + case .sharingAuthorized: + break + @unknown default: + onMain { self.requestHealthKitUpdate() } } diff --git a/Steps4Impact/Settings/TeamSettingsDataSource.swift b/Steps4Impact/Settings/TeamSettingsDataSource.swift index f35cade8..b32dcd18 100644 --- a/Steps4Impact/Settings/TeamSettingsDataSource.swift +++ b/Steps4Impact/Settings/TeamSettingsDataSource.swift @@ -40,7 +40,7 @@ enum TeamMembersContext: Context { case remove(fbid: String, name: String) } -protocol TeamSettingsDataSourceDelegate: class { +protocol TeamSettingsDataSourceDelegate: AnyObject { func updated(team: Team?) } diff --git a/Steps4Impact/Steps4ImpactDebug.entitlements b/Steps4Impact/Steps4ImpactDebug.entitlements new file mode 100644 index 00000000..2ab14a26 --- /dev/null +++ b/Steps4Impact/Steps4ImpactDebug.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.developer.healthkit + + com.apple.developer.healthkit.access + + +