I am making an android app, in which user will share the unique app link to his friends. and if his friend clicks on that link than he/she will be redirected to the play store or app store according to device. and when he/she installs the application then he/she should automatically added to the group of the person who sent the link.
i have successfully done with the creating links.
Thank you in advance
This seems more like an "architectural" type question, but it seems to be that you need to setup a workflow in which clicking on the link creates the new users account and associates it w/ the friend/friends without your web server, then forwards that person to the Play store to download the app. This could happen as several steps in the workflow, but appear as one "step" to the end user, if that's the desired goal, or it could be that you want them to go through the process step-by-step.
As far as how to handle getting the friends linked up, when the link is created, you could generate some unique ID string to tack into the URL. When sent to your server, this link would either contain info that tells your app what to do, or point to some pre-populated data table/file that has what you need. Either way, the URL would signal your web app server what needs to happen.
Keep in mind, we know VERY little about your app based on your description. Also, just to restate, this seems more like a design/architecture issue, not a "code" issue, and should probable be posted in on of the other Stack Exchanges.