Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question I need to get data from the referral link

Discussion in 'Scripting' started by jurec4512, Nov 10, 2020.

  1. jurec4512

    jurec4512

    Joined:
    Aug 16, 2020
    Posts:
    4
    Hello!

    I have a problem and I cannot solve it.
    Help me please!
    I am making a game for android and a referral system.
    At the first start of the game, the user receives a link https://play.google.com/store/apps/details?id=abcdf&referrer=RefID

    In the script I need to get RefID, but I don't know how to do it.

    I searched for information on Google for several days, but without result. Because the information is old or it is not possible to integrate into Unity.
     

    Attached Files:

  2. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    To clarify, you already have the URL in the script, and you just need to extract the referrer parameter from it?
     
    jurec4512 and Bunny83 like this.
  3. jurec4512

    jurec4512

    Joined:
    Aug 16, 2020
    Posts:
    4
    I will clarify.
    This referral parameter is generated on the web server after the first launch of the game in the play market.
    When a user shares a referral link and another user downloads the game from the link provided.
    I need to ask the Play Market if the referral parameter exists or not.
    But I don't know how to do it
     
  4. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Bunny83 and jurec4512 like this.
  5. jurec4512

    jurec4512

    Joined:
    Aug 16, 2020
    Posts:
    4
    I read the latest version of this guide here: https://developer.android.com/google/play/installreferrer/library.html

    The problem is that the api will work after connecting the library in the build.gradle file. But it doesn't work in Unity. I reviewed all the documentation on this api and I could not find how to make it work in Unity.

    But, I did not stop and continued the search. Found an interesting solution on GitHub:https://github.com/uerceg/play-install-referrer-unity#api-playinstallreferrer

    I can't test this solution because I just started developing the game and I don't know if it will work, but it looks good.
     
  6. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    That's because it doesn't work in unity. You need to execute it on the Java side of things:

    Looks like that may work for you. Seems there's a unity utility that allows you to interop with Java code: https://docs.unity3d.com/ScriptReference/AndroidJavaClass.html
     
    jurec4512 likes this.
  7. jurec4512

    jurec4512

    Joined:
    Aug 16, 2020
    Posts:
    4
    Madgvox, thanks for the links. I read the documentation. Now I have a lot of questions :) Probably I'll use the solution from the github.
    The problem is not the interaction between Unity and Java code. The documentation contains code that can be adapted for Unity. There is no documentation or guide on how to integrate this library / api in Unity and this is a mistake of the developers of this api.
    Thank you for your help! Good luck!
     
  8. rizwanbabar693

    rizwanbabar693

    Joined:
    Jul 15, 2016
    Posts:
    15
    @jurec4512 Its been a while. Did you manage to make it work?
     
    rbitard likes this.