I am developing an app which can share and been reward so I use the concept of the dynamic link so to store the information of inviter in that link and later be rewarded. but the PendingDynamicLinkData return null on installing the app after reffered.
MainActivity
FirebaseDynamicLinks.getInstance()
.getDynamicLink(getIntent())
.addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
@Override
public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
// Get deep link from result (may be null if no link is found)
Uri deepLink = null;
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.getLink();
Log.d("successpra", "onSuccess: ");
String referrerUid = deepLink.getQueryParameter("invitedby");
Toast.makeText(SplashActivity.this,referrerUid,Toast.LENGTH_SHORT).show();
}
else
Toast.makeText(SplashActivity.this,"referrerUid",Toast.LENGTH_SHORT).show();
}
});
onclick button of share and earn
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
String uid = user.getUid();
Log.d("prashu",uid);
String link = "https://drive.google.com/open?id=1XUPfiBGCSydmgwEE7E-IRatAeGVuMbOr&?invitedby="+uid;
FirebaseDynamicLinks.getInstance().createDynamicLink()
.setLink(Uri.parse(link))
.setDynamicLinkDomain("nw8y9.app.goo.gl")
.setAndroidParameters(
new DynamicLink.AndroidParameters.Builder("com.example.android")
.setMinimumVersion(125)
.build())
.setIosParameters(
new DynamicLink.IosParameters.Builder("com.example.ios")
.setAppStoreId("123456789")
.setMinimumVersion("1.0.1")
.build())
.buildShortDynamicLink()
.addOnSuccessListener(new OnSuccessListener<ShortDynamicLink>() {
@Override
public void onSuccess(ShortDynamicLink shortDynamicLink) {
Uri mInvitationUrl = shortDynamicLink.getShortLink();
Log.d("prashu",mInvitationUrl.toString());
String referrerName =FirebaseAuth.getInstance().getCurrentUser().getDisplayName();
String subject = String.format("%s wants you to play MyExampleGame!", referrerName);
String invitationLink = mInvitationUrl.toString();
String msg = "Let's play MyExampleGame together! Use my referrer link: "
+ invitationLink;
String msgHtml = String.format("<p>Let's play MyExampleGame together! Use my "
+ "<a href=\"%s\">referrer link</a>!</p>", invitationLink);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, msg);
intent.putExtra(Intent.EXTRA_HTML_TEXT, msgHtml);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
});
Manifest
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="drive.google.com/open?id=1xupfibgcsydmgwee7e-irataegvumbor" android:scheme="http"/>
<data android:host="drive.google.com/open?id=1xupfibgcsydmgwee7e-irataegvumbor" android:scheme="https"/>
</intent-filter>
</activity>
thank u in advance, ur help is appreciable