I even set the policy to .never and the problem persists. Interestingly everything worked with TestFlight before Apple announced that now TestFlight supports HomeWidgets.
				let timeline = Timeline(entries: [entry], policy: .never)
completion(timeline)
Post
Replies
Boosts
Views
Activity
I have implemented the new method in TimeLineProvider but the problem still persists. Seems like a TestFlight problem because the HomeWidget does show up when I install locally.
I adopted the new TimeLineProvider and it works locally but not after I distribute it through TestFlight. It's just broken now. Here is my code: https://developer.apple.com/forums/thread/655182?answerId=623190022#623190022
ok, I implemented the new (in beta 3) method: placeholder(with: Context). The widget shows up on the device when I run locally, but when distributed using TestFlight, HomeWidget disappears and cannot be added.
Here his my code for the TimeLineProvider. What am I missing?
public typealias Entry = SimpleEntry
let dict_dummy = ["Gizmo": ["SOC": 89, "ratedRange": 196, "estimatedRange": 185, "unit": "mi", "isTestUser": true]]
public func snapshot(with context: Context, completion: @escaping (SimpleEntry) -> ()) {
var dict = defaults?.dictionary(forKey: Constants.WIDGET_DICT)
if dict == nil {
dict = dict_dummy
}
let entry = SimpleEntry(date: Date(), dict: dict)
completion(entry)
}
public func timeline(with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
let currentDate = Date()
let refreshDate = Calendar.current.date(byAdding: .minute, value: 10, to: currentDate)!
let dict = defaults?.dictionary(forKey: Constants.WIDGET_DICT)
let entry = SimpleEntry(date: Date(), dict: dict)
let timeline = Timeline(entries: [entry], policy: .after(refreshDate))
completion(timeline)
}
func placeholder(with: Context) -> SimpleEntry {
let entry = SimpleEntry(date: Date(), dict: dict_dummy)
return entry
}
}
@main
struct HomeWidget: Widget {
private let kind: String = "HomeWidget"
public var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
HomeWidgetEntryView(entry: entry)
}
.configurationDisplayName("Stats Widget")
.description("Shows battery SoC and Rated Range")
.supportedFamilies([.systemSmall, .systemMedium])
}
}