The Google Play store allows you to pass in referrer data to your app when a user downloads it, but how can we do this with an APK that is hosted on our own server? This project accomplishes this task without storing the data in a database and fingerprinting the user in order to lookup the data when they run the app. Instead, We just unzip our APK file, then use bash to hex edit a string using search and replace, rebuild (zip) the app, resign it and then serve it using a simple go server.
Initially, the approach was to build the app from source every time a user downloaded the app, but this method was incredibly resource intensive and could cause large delays or even server crashes. The new approach is incredibly quick in comparison and can serve hundreds of users per second on a low tier server.
NOTE: This method probably won't work unless the string you are replacing is the same length every time. Having a different length string may cause issues when rebuilding/resigning the app during some integrity checks. A possible hack would be to have the string in your app the max possible length, then when replacing the string you can pad it with extra characters and remove them at run time in your app.