how to use app links to pass parameter to android playstore to be retrieved when app is installed

心不动则不痛 提交于 2019-11-28 20:33:15

问题


I'm developing a social android trivia game. When a user challenges to a game a friend, who doesn't have my trivia game installed, i'd like to send him a custom url to download the app from the market containing a parameter of the inviting user id.

when the app is run for the first time, i need to be able to receive the parameter passed to the market, in order to identify the user and show him the game he was challenged to. i couldn't figure out how to do this with app links and didn't find any appropriate example.

any help would be greatly welcomed! Thanks, Ido


回答1:


To send data to the Android Market, you have to build an uri like this one:

market://details?id=my.package.name&referrer=someDataToTransfer

To get this data back, you should implement an INSTALL_REFERRER Receiver.

<receiver android:name="my.package.MyReceiver"
          android:exported="true">
   <intent-filter>
   <action android:name="com.android.vending.INSTALL_REFERRER"></action>
   </intent-filter>
</receiver>

Here is a short tutorial that will explain you how to fully implement this solution.

And if you want to test it without writting any code, checkout my app: Install Referrer on GitHub or on the Play Store



来源:https://stackoverflow.com/questions/25466443/how-to-use-app-links-to-pass-parameter-to-android-playstore-to-be-retrieved-when

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!