You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:从Play商店安装应用后获取推荐值及Deep Link参数接收方案

Hey Rajnish, let's tackle these deep linking issues you're facing—both the missing mobile parameter after redirecting from Play Store and capturing referral values post-install. Here's a step-by-step solution tailored to your use case:

Fixing the Missing mobile Parameter After Play Store Redirect

The core issue here is that Google Play Store doesn't pass arbitrary query parameters from its listing URL directly to your installed app. Instead, you need to use Google's official mechanisms to preserve and retrieve this data.

Step 1: Update Your Play Store Redirect URL

Replace your current Play Store link with one that uses the referrer parameter (the only parameter Play Store guarantees to preserve and pass to installed apps). URL-encode your custom mobile and url values inside the referrer parameter:

https://play.google.com/store/apps/details?id=com.mlai.android.skillshaat&referrer=mobile%3D8896203990%26url%3Dhttp%3A%2F%2Fskillshaatapp.com

This ensures your parameters are carried through the Play Store installation flow.

Step 2: Integrate the Google Play Install Referrer API

This API lets your app retrieve the referrer value immediately after installation, so you can extract the mobile parameter.

  1. Add the dependency to your app-level build.gradle:

    dependencies {
        implementation 'com.android.installreferrer:installreferrer:2.2'
    }
    
  2. Implement the API in your app's launch Activity (or a dedicated initialization class):

    import com.android.installreferrer.api.InstallReferrerClient;
    import com.android.installreferrer.api.InstallReferrerStateListener;
    import com.android.installreferrer.api.ReferrerDetails;
    
    // Inside your launch Activity
    private void fetchInstallReferrer() {
        InstallReferrerClient referrerClient = InstallReferrerClient.newBuilder(this).build();
        referrerClient.startConnection(new InstallReferrerStateListener() {
            @Override
            public void onInstallReferrerSetupFinished(int responseCode) {
                switch (responseCode) {
                    case InstallReferrerClient.InstallReferrerResponse.OK:
                        try {
                            ReferrerDetails response = referrerClient.getInstallReferrer();
                            String referrerString = response.getInstallReferrer();
                            // Parse the referrer string to extract your parameters
                            Uri referrerUri = Uri.parse("?" + referrerString);
                            String mobile = referrerUri.getQueryParameter("mobile");
                            String url = referrerUri.getQueryParameter("url");
                            // Save these values to SharedPreferences or process as needed
                        } catch (Exception e) {
                            e.printStackTrace();
                        } finally {
                            referrerClient.endConnection();
                        }
                        break;
                    case InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
                        // Handle older devices that don't support the API
                        break;
                    case InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
                        // Retry later or fall back to alternative methods
                        break;
                }
            }
    
            @Override
            public void onInstallReferrerServiceDisconnected() {
                // Reconnect if the service drops
                referrerClient.startConnection(this);
            }
        });
    }
    

Call fetchInstallReferrer() when your app launches for the first time after installation.

Capturing Referral Values Post-Install

The Install Referrer API solution above directly addresses capturing the mobile referral value after installation. For a more robust, low-maintenance alternative (especially if you need cross-platform support later), consider using Firebase Dynamic Links:

  1. Set up Firebase Dynamic Links for your project.
  2. Create a dynamic link pointing to your original deep link (http://www.skillshaatapp.com/v1/apk?playstore=true&mobile=8896203990), and configure it to redirect to Play Store when the app isn't installed.
  3. Integrate the Firebase Dynamic Links SDK into your app.
  4. Retrieve the deep link parameters in your launch Activity:
    import com.google.firebase.dynamiclinks.FirebaseDynamicLinks;
    import com.google.firebase.dynamiclinks.PendingDynamicLinkData;
    
    FirebaseDynamicLinks.getInstance()
        .getDynamicLink(getIntent())
        .addOnSuccessListener(this, pendingDynamicLinkData -> {
            if (pendingDynamicLinkData != null) {
                Uri deepLink = pendingDynamicLinkData.getLink();
                String mobile = deepLink.getQueryParameter("mobile");
                // Process the mobile parameter as needed
            }
        })
        .addOnFailureListener(this, e -> {
            Log.w(TAG, "Failed to retrieve dynamic link", e);
        });
    

Firebase Dynamic Links automatically handles parameter persistence across app installation, so you don't have to manually manage URL encoding or referrer logic.

Final Checks

  • Ensure your app's deep link intent-filter is correctly configured in AndroidManifest.xml to handle http://www.skillshaatapp.com/v1/apk links (this guarantees the app opens directly with parameters when already installed).
  • Test both flows thoroughly:
    1. App already installed: Click the deep link and confirm mobile is retrieved.
    2. App not installed: Click the link, install from Play Store, open the app and confirm mobile is captured via your chosen method.

内容的提问来源于stack exchange,提问作者Rajnish Kumar Chaubey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:45:15