Hi!
I had 3 In-App purchases (non-renewable subscriptions) in the App store connect account, all Approved and retrieved in the code successfully
Then I added one more free non-renewable subscription In-App purchase, submitted to the app store
New In-App purchase is Approved, all agreements are active, tax and banking info is ok, product identifier in the code is the same as in the App Store connect
I request all four products in SKProductsRequest
But in the productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse)
I receive three old In-App purchase SKProducts, but product identifier of the new In-App purchase is received in invalidProductIdentifiers
Is it Apple's fault, or you have any code recommendations for me?
Post
Replies
Boosts
Views
Activity
Activity Report Extension crashes when adding 3 or more reports on one screen.
I'm trying to use the new Screen Time API from WWDC 2021 and 2022
I'm trying to show 3 reports on one screen, I created a simple SwiftUI app to demonstrate the issue where just a Text for each report is displayed. They all appear for a few seconds and then disappear with an error in the debug console. Our project is stuck because having 1 device activity report for all elements results in poor performance. The whole API seems laggy, but I'm wondering if it's an issue on my side or Apple's bug.
Screen Recording
https://drive.google.com/file/d/1DniOo4QN5bY56sddZJvLTKtkGLQugXRi/view?usp=share_link
I'm getting the following error in the Xcode debug console
2023-09-02 22:36:37.763861-0400 TestApp3[6222:368344] [default] VS terminated with error: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}
All targets and the project have Deployment Target iOS 16, I'm using XCode 14.3.1, and testing on iPhone 11 iOS 16.6
ContentView.swift
struct ContentView: View {
var body: some View {
VStack {
DeviceActivityReport(.init("Total Activity1"))
Spacer(minLength: 16)
DeviceActivityReport(.init("Total Activity2"))
Spacer(minLength: 16)
DeviceActivityReport(.init("Total Activity3"))
}
}
}
ActivityReport.swift
@main
struct ActivityReport: DeviceActivityReportExtension {
var body: some DeviceActivityReportScene {
TotalActivityReport1 { totalActivity in
.init(totalActivity: totalActivity)
}
TotalActivityReport2 { totalActivity in
.init(totalActivity: totalActivity)
}
TotalActivityReport3 { totalActivity in
.init(totalActivity: totalActivity)
}
}
}
TotalActivityReport.swift
extension DeviceActivityReport.Context {
static let totalActivity1 = Self("Total Activity1")
static let totalActivity2 = Self("Total Activity2")
static let totalActivity3 = Self("Total Activity3")
}
struct TotalActivityReport1: DeviceActivityReportScene {
let context: DeviceActivityReport.Context = .totalActivity1
let content: (String) -> TotalActivityView1
func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> String {
"Test1"
}
}
struct TotalActivityReport2: DeviceActivityReportScene {
let context: DeviceActivityReport.Context = .totalActivity2
let content: (String) -> TotalActivityView2
func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> String {
"Test2"
}
}
struct TotalActivityReport3: DeviceActivityReportScene {
let context: DeviceActivityReport.Context = .totalActivity3
let content: (String) -> TotalActivityView3
func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> String {
"Test3"
}
}
TotalActivityView.swift
struct TotalActivityView1: View {
let totalActivity: String
var body: some View {
Text(totalActivity)
}
}
struct TotalActivityView2: View {
let totalActivity: String
var body: some View {
Text(totalActivity)
}
}
struct TotalActivityView3: View {
let totalActivity: String
var body: some View {
Text(totalActivity)
}
}
Hi everyone,
I've been spending my evenings on the app for around 6 months that's using Screen Time API introduced in WWDC 21 (https://developer.apple.com/videos/play/wwdc2021/10123/), I'm having many issues with this API and looking for anyone who has experience with this API, I will appreciate any help or advice I can get!
I'm using DeviceActivityReport to display the dashboard with screen time usage and certain metrics. Device activity report extension runs in an isolated sandbox, which makes it harder to debug and can't make any network call or write to any storage, for privacy purposes which makes sense, but makes it very hard for development.
The issue is that the process where DeviceActivityReport is running crashes for no reason frequently or doesn't run at all. The API itself has many bugs, which is backed up by my experience, Opal app developers and Screen Time even made the news with its bugs. I see the same behaviour with other apps like Opal, but they can workaround somehow it and reload the report.
I'm experienced with UIKit but have little experience with SwiftUI, since ScreenTime API is using SwiftUI only I have to embed DeviceActivityReport in UIKit using UIHostingController and then inside of the device activity report extension target I'm using UIViewControllerRepresentable to embed UIKit into SwiftUI. But I've done some testing and the behaviour is the same when using pure SwiftUI, although there might be fewer hiccups, I couldn't rewrite the whole app.
That's the gist, there's too much code to include, but I can drop more code snippets if there's anyone who has experience with this API who can help me.