-
-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use grouped notifications beta setting in UserDefaults
- Loading branch information
shannon
committed
Jan 14, 2025
1 parent
1ec772d
commit 12d737c
Showing
7 changed files
with
61 additions
and
65 deletions.
There are no files selected for viewing
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
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
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
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
48 changes: 48 additions & 0 deletions
48
MastodonSDK/Sources/MastodonCommon/Preference/Preference+BetaTestSetting.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// BetaTestSetting.swift | ||
// MastodonSDK | ||
// | ||
// Created by Shannon Hughes on 2025-01-13. | ||
// | ||
|
||
import Foundation | ||
|
||
extension UserDefaults { | ||
|
||
public static var isDebugOrTestflightOrSimulator: Bool { | ||
#if DEBUG | ||
return true | ||
#else | ||
guard let path = Bundle.main.appStoreReceiptURL?.path else { | ||
return false | ||
} | ||
return path.contains("CoreSimulator") || path.contains("sandboxReceipt") | ||
#endif | ||
} | ||
|
||
@objc public dynamic var useStagingForDonations: Bool { | ||
get { | ||
register(defaults: [#function: true]) | ||
return bool(forKey: #function) && UserDefaults.isDebugOrTestflightOrSimulator | ||
} | ||
set { self[#function] = newValue } | ||
} | ||
|
||
@objc public dynamic var useGroupedNotifications: Bool { | ||
get { | ||
register(defaults: [#function: true]) | ||
return bool(forKey: #function) && UserDefaults.isDebugOrTestflightOrSimulator | ||
} | ||
set { self[#function] = newValue } | ||
} | ||
|
||
public func toggleUseStagingForDonations() { | ||
let useStaging = UserDefaults.standard.useStagingForDonations | ||
UserDefaults.standard.useStagingForDonations = !useStaging | ||
} | ||
|
||
public func toggleUseGroupedNotifications() { | ||
let useGrouped = UserDefaults.standard.useGroupedNotifications | ||
UserDefaults.standard.useGroupedNotifications = !useGrouped | ||
} | ||
} |
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
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