Created
February 4, 2020 01:32
-
-
Save pyeongho/a129329471269e1b9fcf09d6a19c24b5 to your computer and use it in GitHub Desktop.
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
val referrerClient: InstallReferrerClient = InstallReferrerClient.newBuilder(this).build() | |
referrerClient.startConnection(object : InstallReferrerStateListener { | |
override fun onInstallReferrerSetupFinished(responseCode: Int) { | |
when (responseCode) { | |
InstallReferrerClient.InstallReferrerResponse.OK -> { | |
// Connection established | |
val response: ReferrerDetails = referrerClient.installReferrer | |
Log.d("TAG",response.installReferrer) | |
referrerClient.endConnection() | |
} | |
InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> { | |
// API not available on the current Play Store app | |
mReferrerTrigger.onNext(Pair(false, "")) | |
} | |
InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE -> { | |
// Connection could not be established | |
} | |
else -> { | |
} | |
} | |
} | |
override fun onInstallReferrerServiceDisconnected() { | |
// Try to restart the connection on the next request to | |
// Google Play by calling the startConnection() method. | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment