locked
How to get Install referrer for an app RRS feed

  • Question

  • User390255 posted

    Hi!

    I'm working on a xamarin library and I'm trying to receive INSTALLREFERRER of android apps that use the sdk. I haven't found any example using Xamarin and INTALLREFERRER and I have no experience with BroadcastReceivers, so I don't know if I'm doing it right. I'm using the following code: ``` using Android.Content; using System; using System.Collections.Generic; using System.Text;

    using Android.OS; using Android;

    namespace Plugin.MySDK.Shared { [BroadcastReceiver(Exported = true, Name ="com.sdk.ReferrerReciever", Permission = "android.permission.INSTALLPACKAGES")] [Android.App.IntentFilter(new[] { "com.android.vending.INSTALLREFERRER" })] public class ReferrerReciever : BroadcastReceiver {

        public override void OnReceive(Context context, Intent intent)
        {
            // I don't know what to do here
        }
    }
    

    } ``` Please how do I get the referrer and assign it to a variable so that I can use it for something else

    Thursday, November 14, 2019 11:15 AM

Answers

  • User379860 posted

    Your BroadcastReceiver is correct, when you execute the onReceive method. You can get the referrer information by intent.GetStringExtra("referrer");.

     @Override
     public override void OnReceive(Context context, Intent intent) {
        string referrer = intent.GetStringExtra("referrer");
        // Send referrer information to the third-party server
      }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, November 14, 2019 1:30 PM

All replies

  • User379860 posted

    Your BroadcastReceiver is correct, when you execute the onReceive method. You can get the referrer information by intent.GetStringExtra("referrer");.

     @Override
     public override void OnReceive(Context context, Intent intent) {
        string referrer = intent.GetStringExtra("referrer");
        // Send referrer information to the third-party server
      }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, November 14, 2019 1:30 PM
  • User392598 posted

    Hi @atuma! I have the same issue. Can you send your AndroidManifest.xml if your broadcast receiver is working correct?

    Wednesday, February 5, 2020 10:16 AM
  • User398833 posted

    I would like to pass ToekenId and request type from playstore and will get in OnReceive function,

    here how I decide which page will be first page based on request type?

    do need to register this ReferrerReciever in MainActivity>OnCreate?

    Wednesday, January 6, 2021 11:32 PM
  • User387922 posted

    @LeonLu said: Your BroadcastReceiver is correct, when you execute the onReceive method. You can get the referrer information by intent.GetStringExtra("referrer");.

     @Override
     public override void OnReceive(Context context, Intent intent) {
        string referrer = intent.GetStringExtra("referrer");
        // Send referrer information to the third-party server
      }
    

    Hi, can I have more details about the implementation?

    Monday, March 8, 2021 10:47 AM