0

Tell me how you can get install referrer in Unity3D. I made an android plugin in which I created a class inherited from the broadcastreceiver. And in the onreceive method, I send data, but the onreceive method is not called. The receiver has been added to the plugin Manifest and Unity manifest.Manifest:

<receiver
    android:name="com.ahg.and.InstallReferrerReceiver"
    android:exported="true"
    android:permission="android.permission.INSTALL_PACKAGES">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

BroadcastReceiver:

public class InstallReferrerReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String referrer = intent.getStringExtra("referrer");

        UnityPlayer.UnitySendMessage("Loader", "GetReferrer",referrer);
    }
}

Please tell me, for what reason is not called broadcastreceiver?

Will
  • 413
  • 6
  • 23
Stelette
  • 50
  • 2
  • 9

2 Answers2

1

Above described way of obtaining referrer information (with INSTALL_REFERRER intent) is nowdays deprecated by Google in favour of install referrer API. I made small Unity plugin which provides referrer information by using the new approach. You can find it in here: https://github.com/uerceg/play-install-referrer-unity

Cheers

uerceg
  • 4,637
  • 6
  • 45
  • 63
0

I will write to those who are interested in this problem: in OnReceive you need to call non-unity methods ( since broadcastreceiver is called before the application starts) then I save string referrer through sharedpreferences , and then check it in unity at startup. I hope this helps someone.

Stelette
  • 50
  • 2
  • 9