-
Notifications
You must be signed in to change notification settings - Fork 2
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
Admob Ads Calling Mechanism while VPN is connected #30
Comments
Is there anyone to give the answer ? |
Hello you need to handle by external code You can use Android's ConnectivityManager to manage network traffic and route certain requests outside of the VPN, i.e., make the AdMob traffic go directly through the device's default network interface, bypassing the VPN. Step 1: Get the Default Network (Outside VPN) Use ConnectivityManager to retrieve the default network, which isn’t affected by the VPN. This will allow you to send the AdMob requests through the default network, even if the VPN is connected. java ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); Step 2: Set Up Network-Specific Traffic With Android 10 (API level 29) and higher, you can use the bindProcessToNetwork() method to bind your process or specific ad requests to a particular network, such as the default network. java connectivityManager.bindProcessToNetwork(defaultNetwork); This will route traffic through the network interface that is not using the VPN. Step 3: Send AdMob Requests After binding to the default network, any HTTP requests or SDK calls (such as AdMob ad requests) will bypass the VPN. You can switch the network binding dynamically based on your needs. After serving the ads, you can unbind from the network by calling: java
If you are handling HTTP requests to AdMob directly, you can configure your HTTP client to use the default network.
URL url = new URL("https://googleads.g.doubleclick.net/"); Step 2: Use Retrofit or OkHttp (Optional): If you’re using a network library like Retrofit or OkHttp, you can modify them to bind to a specific network when sending HTTP requests. |
When VPN is not connected ads request will be from my original API. And if VPN connect admob ads requests will be from different IP address. Google admob will detect and block the ads. How these SDKs are handling this issue ?
The text was updated successfully, but these errors were encountered: