Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 14 widgets #134

Merged
merged 2 commits into from
Oct 21, 2020
Merged

iOS 14 widgets #134

merged 2 commits into from
Oct 21, 2020

Conversation

rhcpfan
Copy link
Contributor

@rhcpfan rhcpfan commented Oct 20, 2020

Notes

Widgets have a maximum peak memory usage of 30Mb. If this is exceeded, they will crash and you'll see a placeholder instead.

Implementation

  • Added public func fetchWidgetsData(completion: @escaping (Bool) -> Void) to DataManager in order to get only some basic data from JHU. This was implemented in order to reduce memory usage and keep it under the 30Mb limit;
  • Implemented two sizes of widgets: .systemSmall and .systemMedium that provide data by country. If no country is selected, they display Worldwide data;
  • Refresh is once per hour. This is not a guarantee since the OS decides if it should refresh the widgets or not depending on the device conditions. Only thing we can do is to specify a TimelineReloadPolicy equal to .after(nextRefreshDate) where nextRefreshDate is 1 hour after the current date;
  • Widgets have deep links that will open the application and display the country selected on the widget (there's an issue in the current version of the app where after an update the selected country will be deselected; hopefully it will be fixed soon). The format of the deep link is:
urlComponents.scheme = "coronatracker"
urlComponents.host = "ios_14_widget"
urlComponents.path = "/open"
urlComponents.queryItems = [URLQueryItem(name: "region", value: countryIsoCode)]

add a method to get some basic widgets data from JHW

iOS widgets implementation

refresh widgets once every hour

widgets deeplinks

revert JHURepoDataService.swift
@rhcpfan rhcpfan changed the title Ios 14 widget Ios 14 widgets Oct 20, 2020
@rhcpfan rhcpfan changed the title Ios 14 widgets iOS 14 widgets Oct 20, 2020
@mhdhejazi
Copy link
Owner

Superb! Thank you so much for the great work and detailed description.

I'll merge this after merging #133.

@mhdhejazi mhdhejazi merged commit 3ea6dc2 into mhdhejazi:master Oct 21, 2020
@mhdhejazi
Copy link
Owner

Thank you again for the great work!

@FelikZ FelikZ mentioned this pull request Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants