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

Post Notification when a .notConnectedToInternet URLError is re… #46

Merged
merged 2 commits into from
Jul 2, 2020

Conversation

BenShutt
Copy link
Contributor

@BenShutt BenShutt commented Jul 2, 2020

Post Notification when a .notConnectedToInternet URLError is returned as the Error of a URL task

Related Issue

Motivation and Context

Apps can listen and respond to this Notification and handle accordingly, often with UI.

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@BenShutt BenShutt requested a review from simonmitchell July 2, 2020 13:55
@@ -74,6 +79,10 @@ extension RequestController {

NotificationCenter.default.post(name: RequestController.DidReceiveResponseNotificationName, object: nil, userInfo: requestInfo)

if let urlError = error as? URLError, urlError.code == .notConnectedToInternet {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be more generic here and have a notification similar to below? RequestController.DidNetworkErrorNotificationName? We could just whack the error into the requestInfo dictionary and do the checking in the consuming app then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm that's not a bad point at all. Maybe al URLErrors? can easily then check for urlError.code == .notConnectedToInternet. I'll make that change if you agree? Or have any other suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@BenShutt BenShutt merged commit 8ae05e3 into develop Jul 2, 2020
@BenShutt BenShutt deleted the feature/no-internet-notification branch September 21, 2021 09:34
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