How to implement referral program in mobile Apps for both Android and iPhone

前端 未结 7 2297
无人共我
无人共我 2020-12-22 17:29

We have a mobile app that\'s available in both Google Play Store and Apple AppStore, we want to implement a referral program to get more users to install and use our App.

7条回答
  •  無奈伤痛
    2020-12-22 18:01

    Gradle File

     implementation 'com.android.installreferrer:installreferrer:1.0'
    

    PUT CODE IN ACTIVITY WHERE IT NEED TO RECIEVE REFFERAL CODE

     InstallReferrerClient mReferrerClient;
    
     mReferrerClient = InstallReferrerClient.newBuilder(this).build();
    
     mReferrerClient.startConnection(new InstallReferrerStateListener() {
     @Override
     public void onInstallReferrerSetupFinished(int responseCode) {
                switch (responseCode) {
                    case InstallReferrerClient.InstallReferrerResponse.OK:
                        // Connection established
                        try {
                            ReferrerDetails response = 
     mReferrerClient.getInstallReferrer();
                            if (!response.getInstallReferrer().contains("utm_source"))
                                edtPRferelCode.setText("" + 
     response.getInstallReferrer());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        mReferrerClient.endConnection();
                        break;
                    case 
     InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED:
                        // API not available on the current Play Store app
                        break;
                    case 
     InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE:
                        // Connection could not be established
                        break;
                }
            }
    
            @Override
            public void onInstallReferrerServiceDisconnected() {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
            }
        });
    

    SHARE LINK EXAMPLE

    https://play.google.com/store/apps/details?id=com.yourpackage&referrer=9BE46300

提交回复
热议问题