Created
February 17, 2024 05:38
-
-
Save Kudo/8c6becbb553c7b2c9baeb4b9b0e7616e to your computer and use it in GitHub Desktop.
Customize User-Agent for Expo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/android/app/src/main/java/dev/expo/kudo/sdk50/MainApplication.kt b/android/app/src/main/java/dev/expo/kudo/sdk50/MainApplication.kt | |
index e9a2f7a..fbf9aae 100644 | |
--- a/android/app/src/main/java/dev/expo/kudo/sdk50/MainApplication.kt | |
+++ b/android/app/src/main/java/dev/expo/kudo/sdk50/MainApplication.kt | |
@@ -14,10 +14,12 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load | |
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost | |
import com.facebook.react.defaults.DefaultReactNativeHost | |
import com.facebook.react.flipper.ReactNativeFlipper | |
+import com.facebook.react.modules.network.OkHttpClientProvider | |
import com.facebook.soloader.SoLoader | |
import expo.modules.ApplicationLifecycleDispatcher | |
import expo.modules.ReactNativeHostWrapper | |
+import okhttp3.Interceptor | |
class MainApplication : Application(), ReactApplication { | |
@@ -55,6 +57,14 @@ class MainApplication : Application(), ReactApplication { | |
if (BuildConfig.DEBUG) { | |
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager) | |
} | |
+ OkHttpClientProvider.setOkHttpClientFactory { | |
+ OkHttpClientProvider.createClientBuilder() | |
+ .addInterceptor(Interceptor { chain -> | |
+ val request = chain.request().newBuilder().header("User-Agent", "My-UA").build() | |
+ chain.proceed(request) | |
+ }) | |
+ .build() | |
+ } | |
ApplicationLifecycleDispatcher.onApplicationCreate(this) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cng-patches/android+e595dc4a98abafdbbb9eb9979064bb34.patch that is manually changed and generated by
bunx patch-project -p android