Post

Replies

Boosts

Views

Activity

Widget is crashing with 1: EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=30 MB, unused=0x0)
I have created widget which supports medium and large family similar to news feed app like title and image by configuring the medium widget with 2 articles and large with 4 articles where each article has title and it's image with size 46x46 and 61x61. When am adding the small and large widgets to my Home Screen getting memory limit (Thread 1: EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=30 MB, unused=0x0)(crash and the widget is not refreshing and some times widgets is showing the skeletons instead of data. This is my timeline provider     func getTimeline(in context: Context, completion: @escaping (Timeline) -> Void) {             widgetVM.getRecommendedDataForWidget{ (result) in                 switch result {                 case .success(let items):                     let entries =  getRecommendedWidgetTimeLineEntries(recFeedModel: items)                     let timeline = Timeline(entries: entries, policy: .atEnd)                     completion(timeline)                 case .failure(_):                         let entry = RecommendedWidgetEntry(date: Date(), recommedationData: WidgetFeedModel.getPlaceholderData())                         let timeline = Timeline(entries: [entry], policy: .never)                         completion(timeline)                 }             }         }         else {             if accessTokenValue == nil { // if token is nil then considering it as member is not logged in.                 let entry = RecommendedWidgetEntry(date: Date(), recommedationData: [])                 let timeline = Timeline(entries: [entry], policy: .never)                 completion(timeline)                 return             }     } Could you please help me out on this as this is priority for me as part of app release. I couldn't find out the reason for this. Thanks
9
0
2.9k
Sep ’22
Widget is not auto refreshing
Widget needs to be auto refreshed at 6AM & 6PM every day. I have added the following logic/code based on the widget adding time. But I could not see the widget is auto refreshing at 6AM & 6PM let calendar = Calendar.current           let TimeComponentfor6AM = DateComponents(calendar: calendar, hour:6)           let TimeComponentfor6PM   = DateComponents(calendar: calendar, hour: 18, minute: 00)           let now = Date()           let startOfToday = calendar.startOfDay(for: now)           let startTime    = calendar.date(byAdding: TimeComponentfor6AM, to: startOfToday)!           let endTime      = calendar.date(byAdding: TimeComponentfor6PM, to: startOfToday)!         if now < startTime {//if widget adds before 6AM             if let At6AM = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: Date()) {                 let refreshEntryFor6AM = RecommendedWidgetEntry(date: At6AM, recommedationData: recFeedModel)                 refreshEntries.append(refreshEntryFor6AM)             }             if let At6PM = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: Date()) {                 let refreshEntryFor6PM = RecommendedWidgetEntry(date: At6PM, recommedationData: recFeedModel)                 refreshEntries.append(refreshEntryFor6PM)             }             return refreshEntries         }         else if now < endTime { //if the widget adds before 6PM             if let At6PM = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: Date()) {                 let refreshEntryFor6PM = RecommendedWidgetEntry(date: At6PM, recommedationData: recFeedModel)                 refreshEntries.append(refreshEntryFor6PM)             }             let today = Date()             if let nextDayDate = Calendar.current.date(byAdding: .day, value: 1, to: today)             {                 if let At6AM = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: nextDayDate) {                     let refreshEntryFor6AM = RecommendedWidgetEntry(date: At6AM, recommedationData: recFeedModel)                     refreshEntries.append(refreshEntryFor6AM)                 }             }             return refreshEntries         }         else { // if widget added post 6PM             let today = Date()             if let nextDayDate = Calendar.current.date(byAdding: .day, value: 1, to: today)             {                 if let At6AM = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: nextDayDate) {                     let refreshEntryFor6AM = RecommendedWidgetEntry(date: At6AM, recommedationData: recFeedModel)                     refreshEntries.append(refreshEntryFor6AM)                 }                 if let At6PM = Calendar.current.date(bySettingHour: 18, minute: 0, second: 0, of: nextDayDate) {                     let refreshEntryFor6PM = RecommendedWidgetEntry(date: At6PM, recommedationData: recFeedModel)                     refreshEntries.append(refreshEntryFor6PM)                 }             } Kindly help me on it if anything missed or need to be added
3
0
490
Sep ’22