-
Notifications
You must be signed in to change notification settings - Fork 122
Adds NSURLSession delegate to MGLNetworkConfiguration #228
Conversation
cc @halset (who proposed a session delegate PR). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs tests
@julianrex Thanks for the cc! Should probably recreate the |
@halset I'm thinking this PR would make the existing session delegate PR redundant. Note this is still just an experiment, and we may end up adding a delegate for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Build issues aside. LGTM I left minor comments. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to split out the build system changes into a separate PR? It isn’t clear to me how they relate to MGLNetworkConfiguration.
platform/ios/Integration Tests/MGLNetworkConfigurationIntegrationTests.mm
Show resolved
Hide resolved
8014911
to
8e21644
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julianrex and I went over these changes over the phone.
👍 from me, but echoing @1ec5's comments about the build changes being broken out in another PR if possible.
@@ -34,26 +40,46 @@ + (instancetype)sharedManager { | |||
_sharedManager = [[self alloc] init]; | |||
}); | |||
|
|||
[self setNativeNetworkManagerDelegateToDefault]; | |||
// Notice, this is reset for each call. This is primarily for testing purposes. | |||
// TODO: Consider only calling this for testing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to-do still relevant? (×2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a new ticket to track this.
@@ -23,12 +49,14 @@ MGL_EXPORT | |||
If this property is set to nil or if no session configuration is provided this property | |||
is set to the default session configuration. | |||
|
|||
Assign this object before instantiating any `MGLMapView` object. | |||
Assign this object before instantiating any `MGLMapView` object, or using | |||
`MGLOfflineStorage` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What’s an example of a place where this object can be assigned safely? Consider that fixing #227 may require us to invoke +[MGLOfflineStorage sharedStorage]
in an +initialize
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. Let's address that when we fix #227. Hopefully we can find a way around without having to use an +initialize
.
69b78ce
to
7dc7111
Compare
Build changes were refactored into #242
When merged, the commit will need to be cherry-picked to |
ec7c140
to
f6903cd
Compare
Add expect-to-fail test for data delegate.
Co-Authored-By: Minh Nguyễn <[email protected]>
f6903cd
to
9d2efab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested this with a tile source that uses HTTP Basic Authentication by using a NSURLSession
with a custom NSURLSessionDelegate
. It works fine! So for me, this can replace my original PR. Thank you for the good work!
Depends on #242
This PR adds an undocumented
MGLNetworkConfigurationSessionDelegate
and aid delegate
property toMGLNetworkConfiguration
.This allows the application to provide an
NSURLSession
object, which will be used instead of one being created using the existingsessionConfiguration
property. It is the developer's responsibility to maintain the life (and reuse) the session object. It's also important to note that the delegate method does not get called on the main thread.Background sessions are not supported, and an exception will fire if one is supplied - this exception is provided by the OS.
The existing
sessionConfiguration
behavior remains unchanged.To enable these changes, the PR also includes:
MGLNetworkIntegrationManager
(non-public type) - this was just acting as a go-between, as was superfluous.MGLIntegrationTestCase
to share existing testing functionality.TODO:
See also these changes in gl-native, which this PR depends on.