2

I want to test my own app before going live after integrating with Huawei install Referrer SDK. I followed all the steps found in codelabs and the documentations and when i install the apk on the device , getInstallReferrer method throws IOException. This is my code. What is it that i am doing wrong ?. how can i get installReferrer info for testing purposes ?

       Runnable {
            referrerClient = newBuilder(context).setTest(true).build()
            referrerClient.startConnection(object : InstallReferrerStateListener {

                @SuppressLint("SwitchIntDef")
                override fun onInstallReferrerSetupFinished(responseCode: Int) {
                    when (responseCode) {
                        InstallReferrerClient.InstallReferrerResponse.OK -> {
                            // Connection established.
                            try {
                                val response: ReferrerDetails = referrerClient.installReferrer
                                val referrerUrl: String = response.installReferrer
                                val referrerClickTime: Long = response.referrerClickTimestampSeconds
                                val appInstallTime: Long = response.installBeginTimestampSeconds
                            }catch (e : IOException){
                                Log.i("INSTALL_REFERRER","IOException")
                            }
                            catch(e: RemoteException){
                                Log.i("INSTALL_REFERRER","RemoteException")
                            }
                            finally {
                                referrerClient.endConnection()
                            }


                        }
                        InstallReferrerClient.InstallReferrerResponse.FEATURE_NOT_SUPPORTED -> {
                           
                            Log.i("INSTALL_REFERRER","NOT AVAILABLE")
                        }
                        InstallReferrerClient.InstallReferrerResponse.SERVICE_UNAVAILABLE -> {
                           
                            Log.i("INSTALL_REFERRER","SERVICE UNAVAILABLE")
                        }
                    }
                }

                override fun onInstallReferrerServiceDisconnected() {
                    Log.i("INSTALL_REFERRER","ReferrerServiceDisconnected")
                }
            })
        }.run()

1 Answers1

0

Please check whether the AIDL interface is added.

Check the screenshot below: enter image description here

  • Obtain Install Referrer Information by AIDL

You can call an AIDL API provided by HUAWEI Ads Kit to obtain install referrer information from HUAWEI devices, without integrating any HUAWEI SDK. The install referrer information obtained from a device in either mode (SDK or AIDL) is the same.

  • Call Process enter image description here

  • The Development Procedure is as follows

  1. Create an AIDL file for the IPPSChannelInfoService API and save the file.

  2. Copy the following content to the AIDL file:

    package com.huawei.android.hms.ppskit;
    /** Important: Do not change the method sequence in the AIDL file. */
    interface IPPSChannelInfoService {
    String getChannelInfo();
    }

  3. Change Build Action to AndroidInterfaceDescription of AIDL file.

  4. Rebuild project.

  5. Create a class to implement Android-native IServiceConnection.

For more details, see docs. Also, please kindly refer to the demo.

Update:

  1. The package name needs to be specified because setTest(true)

    if (this.isTest){ var2 = "com.huawei.pps.hms.test"; }

  2. The empty check on ReferrerDetails can be added.

    if (null != referrerDetails && null != mCallback)

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • 1
    as i understood from the documentation, AIDL method is another way of implementing InstallReferrer but not a completion for the first method (the SDK method) . Am i missing something? – Yomna Gamal Aug 17 '20 at 06:12
  • @YomnaGamal Yes, I update my answer. Please check your package name "com.huawei.pps.hms.test". And please add the empty check on ReferrerDetails. – zhangxaochen Aug 20 '20 at 03:15
  • I have checked the demo link but I found out that his application package name is the one you mentioned but how could i change my application package name knowing that it is already live on app gallery ? – Yomna Gamal Aug 29 '20 at 21:33
  • @YomnaGamal The package name cannot be changed if it is already on App Gallery, unless you create a new one on the AGC. And you don't need to. Here is the thing, if you setTest(true) , your package name should be "com.huawei.pps.hms.test" ,and that's for test . To get get intall referrer of your own app , you need to publish your app in Huawei App Gallery, and download your app . If you have any more questions, feel free to contact me. – zhangxaochen Sep 02 '20 at 00:49
  • @YomnaGamal I have the same problem. I try launch two test project on my Honor 10, https://github.com/huaweicodelabs/Ads/tree/master/InstallReferrer and https://github.com/HMS-Core/hms-codelabs/tree/master/Ads%20Kit%20(Install%20Referrer) In both cases i get `getInstallReferrer IOException: getInstallReferrer not found installreferrer`. I can't figure out what I'm doing wrong – Владислав Прасков May 28 '21 at 09:03
  • @ВладиславПрасков hey! did you figure out what was wrong? – lishee loo Jan 30 '23 at 10:57