Refactor StoreKit 2 subscription system and add interactive vote widget

## StoreKit 2 Refactor
- Rewrote IAPManager with clean enum-based state model (SubscriptionState)
- Added native SubscriptionStoreView for iOS 17+ purchase UI
- Subscription status now checked on every app launch
- Synced subscription status to UserDefaults for widget access
- Simplified PurchaseButtonView and IAPWarningView
- Removed unused StatusInfoView

## Interactive Vote Widget
- New FeelsVoteWidget with App Intents for mood voting
- Subscribers can vote directly from widget, shows stats after voting
- Non-subscribers see "Tap to subscribe" which opens subscription store
- Added feels:// URL scheme for deep linking

## Firebase Removal
- Commented out Firebase imports and initialization
- EventLogger now prints to console in DEBUG mode only

## Other Changes
- Added fallback for Core Data when App Group unavailable
- Added new localization strings for subscription UI
- Updated entitlements and Info.plist

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-09 23:07:16 -06:00
parent c8248429dd
commit f2c510de50
34 changed files with 1267 additions and 1048 deletions

View File

@@ -147,30 +147,7 @@ struct SettingsView: View {
}
private var subscriptionInfoView: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
PurchaseButtonView(iapManager: iapManager, showManageSubClosure: {
Task {
await
self.showManageSubscription()
}
}, showCountdownTimer: true)
if iapManager.showIAPWarning {
Button(action: {
Task {
await iapManager.restore()
}
}, label: {
Text(String(localized: "purchase_view_restore"))
.font(.title3)
.padding([.top, .bottom])
})
}
}
}
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
PurchaseButtonView(iapManager: iapManager)
}
private var closeButtonView: some View {
@@ -245,7 +222,9 @@ struct SettingsView: View {
tmpDate = Calendar.current.date(byAdding: .minute, value: -59, to: tmpDate)!
tmpDate = Calendar.current.date(byAdding: .second, value: -45, to: tmpDate)!
firstLaunchDate = tmpDate
iapManager.updateEverything()
Task {
await iapManager.checkSubscriptionStatus()
}
}, label: {
Text("Set first launch date back 29 days, 23 hrs, 45 seconds")
.foregroundColor(textColor)
@@ -255,13 +234,15 @@ struct SettingsView: View {
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
private var resetLaunchDate: some View {
ZStack {
theme.currentTheme.secondaryBGColor
Button(action: {
firstLaunchDate = Date()
iapManager.updateEverything()
Task {
await iapManager.checkSubscriptionStatus()
}
}, label: {
Text("Reset luanch date to current date")
.foregroundColor(textColor)
@@ -590,16 +571,6 @@ struct SettingsView: View {
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
func showManageSubscription() async {
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene{
do {
try await StoreKit.AppStore.showManageSubscriptions(in: windowScene)
iapManager.updateEverything()
} catch {
print("Sheet can not be opened")
}
}
}
}
struct TextFile: FileDocument {