-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ios: Support custom NSURLProtocol #12026
Comments
Having thought about it a little bit more, I think it'd be best if it'd be possible to provide the whole Still no clue how to go about this, though oO ARCHITECTURE.md affirms my understanding that the SDK uses and accesses the C++ core, not the other way around. Could we have a |
Would be really nice to have this. |
Not from the SDK’s public API, because the SDK is intended to be compatible with pure Objective-C projects, whereas mbgl’s public API is entirely in C++. It is possible for the SDK’s internal code to interact with mbgl’s public API, but the networking code is internal even to mbgl.
This is true for the most part. mbgl does have some platform-specific Objective-C++ code at the very lowest level for working with NSURLSession. @kkaefer, do you think we could expose a way for developers to customize NSURLSessionConfiguration? I think this would be one important step towards resolving #4291 as well. /cc @julianrex |
I think it's also worth looking at what's happening over in the Android version re customizing networking. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
This might be a way to go forward: #13491 |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
Stay open, plz. |
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions. |
@fabian-guerra is there a label we can add so the stale bot ignores it? (and remove the "archived" label) Edit: No, there currently isn't. So the project would need a new label and a |
Still, stalebot seems to be malfunctioning — unsure why it’s trying to continually close issues after mere hours of inactivity. /cc @tmpsantos |
I'm going to assign this to me for now. |
It is because the label |
For those of you who land on this page and looking for similar capability on the Android side, read this ticket: |
Platform: iOS
Mapbox SDK version: 4.0
Based on the discussion in #3597.
To modify the HTTP request headers or, in general, handle all sorts of remote requests, it's desirable to be able to use custom
NSURLProtocol
implementations. For this to work, we'd need a way to addNSURLProtocol
classes toNSURLSessionConfiguration.protocolClasses
(as described here).How would we go about this? A delegate call? A class property?
I'm unfamiliar with the codebase but this is as I understand it so far:
NSURLSession
is created inHTTPFileSource::Impl()
indarwin/src/http_file_source.mm
DefaultFileSource::Impl()
inplatform/default/default_file_source.cpp
SDKOfflineStorage-init
inSDK/Foundation/Offline Maps/SDKOfflineStorage.mm
(real path isdarwin/src/MGLOfflineStorage.mm
)[MGLOfflineStorage sharedOfflineStorage].mbglFileSource
being accessed inMGLRendererConfiguration.fileSource
inSDK/Foundation/MGLRendererConfiguration.mm
(alsodarwin/src/
)MGLMapView-commonInit
inSDK/Kit/MGLMapView.mm
(ios/src/
)So, MapView -> Renderer -> Offline Storage -> Default File Source -> HTTP File Source.
SDKOfflineStorage
andMGLMapView
do have delegates, but we can't use either becauseHTTPFileSource::Impl()
is called during their initialization. We could add an additional parameter to anMGLMapView-init
variation. However that would require to pass it throughplatform/
default
/default_source_file.cpp
, which is undesirable, I guess. The only option I see would be a class property on...some class.HTTPFileSource
doesn't have a ObjC pendant yet. Could we add one? Or have it access some other global state thing?The Android solution is implemented in #10948. Would the equivalent be to have
SDK/[Foundation|Kit]/MGLHTTPRequestUtil.{h,mm}
and access that inHTTPFileSource::Impl()
?Edit: Is it even possible to access anything in the SDK part from the platform part?
I'm pretty much lost here. Any thoughts, @1ec5? Could you point me in a direction?
Also, are fonts/glyphs downloaded via the same mechanism?
The text was updated successfully, but these errors were encountered: