I have a question. Can we add a invite button to the mobile app in android studio which on clicking gives referral link of the website instead of the application itself? Can we use firebase dynamic link for this or is it only to refer app itself? I have added the code for dynamic link but its only to refer mobile app and not the website. I'd like to know if we can refer website as well.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_refer);
invite = findViewById(R.id.inviteBtn);
// calling the action bar
ActionBar actionBar = getSupportActionBar();
// showing the back button in action bar
actionBar.setDisplayHomeAsUpEnabled(true);
invite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
inviteLink();
}
});
}
public void inviteLink(){
Log.e("main", "invite link");
DynamicLink dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse("https://www.versatileva.com.au/"))
.setDomainUriPrefix("versatileva.page.link")
.setAndroidParameters(new DynamicLink.AndroidParameters.Builder().build())
.setIosParameters(new DynamicLink.IosParameters.Builder("com.android.versatilevaproject").build())
.buildDynamicLink();
Uri dynamicLinkUri = dynamicLink.getUri();
Log.e("main", " Long refer " dynamicLink.getUri());
//versatileva.page.link?apn=com.android.versatilevaproject&ibi=com.android.versatilevaproject&link=https://www.versatileva.com.au/
}
}
CodePudding user response:
Firebase provide this guide on rewarding user referrals using Dynamic Links. You can use Dynamic Links along with Realtime Database and Cloud Functions for Firebase to encourage your users to invite their friends by offering in-app rewards for successful referrals to both the referrer and the recipient.