I use unique codes to update scores in my leaderboard databases.
With people who have multiple devices (phone, tablet) I kept in mind that scores should be transferable or updating while playing on multiple devices.
To be able to transfer the code I had a screen where you could see or type in another code.
When the people from Apple saw this, after it was already several years active, they called me that I had to remove that.
They think it's a way to give users extra features while bought via another method than their app store.
So your referal code might be a risky thing unless you do it via some web based method outside the app.
But how will you track if the app was actually installed before you grant some gifts?
Then you'll need to let the new user enter some info (email address or referal code?)