facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.6k stars 24.28k forks source link

NSURLSession with custom delegate (didReceiveChallenge) or custom NSURLSession #33195

Closed Oref closed 6 months ago

Oref commented 2 years ago

Description

For our customer we are developing an application which runs in MDM solution Mobile Iron. The app needs to connect to backend API server. To do that each request must be authorized with certificate (obtained from Mobile Iron's AppConnect library).

Is it possible to provide our custom NSURLSession or provide our custom delegate for the session?

We did't find any solutions. All we have found is how to make custom NSURLSessionConfiguration in this PR #27701, but this does not solve our problem with request authorization.

Version

0.66.0

Output of npx react-native info

info Fetching system and libraries information... System: OS: macOS 11.6 CPU: (8) x64 Apple M1 Memory: 25.54 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - /usr/local/bin/node Yarn: Not Found npm: 6.14.10 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 13.0/13A233 - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.0 => 0.66.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

It's not a bug, it's a question about functionality. So providing steps to reproduce doesn't make sense.

Snack, code example, screenshot, or link to a repository

No response

peto7373 commented 2 years ago

@Oref I have the same problem. Did you find a solution?

hakonk commented 2 years ago

Have you looked into whether you can swizzle the url session delegate implementations @Oref ? Otherwise, I think you would have to implement a customization point where a custom delegate can be passed. To me it seems the URL session delegate is implemented here: https://github.com/facebook/react-native/blob/8bd3edec88148d0ab1f225d2119435681fbbba33/Libraries/Network/RCTNetworkTask.mm

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 6 months ago

This issue was closed because it has been stalled for 7 days with no activity.