io为我的Android应用程序制作推荐程序。我根据此处描述的分支文档集成https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/
安装跟踪和奖励用户工作正常,但如果我使用用户推荐链接安装它不起作用。不要给影响者奖励。
这是我的代码
在清单
中<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="io.branch.referral.BranchApp"
>
<activity android:name="com.video.watch.earn.ActivityMain"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="videotopro" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
在java类MainActivity中
//branch io
@Override
public void onStart() {
super.onStart();
final Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession(new Branch.BranchReferralInitListener(){
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
Log.i("BranchConfigTest", "deep link data: " + referringParams.toString());
} else {
Log.i("MyApp", error.getMessage());
}
}
}, this.getIntent().getData(), this);
String userID = new BigInteger(130, new SecureRandom()).toString(32);
branch.getInstance().setIdentity(userID);
Branch.getInstance(this.getApplicationContext()).loadRewards(new Branch.BranchReferralStateChangedListener() {
@Override
public void onStateChanged(boolean changed, BranchError error) {
int credits = branch.getCredits();
Log.d("branch credit",""+credits);
}
});
}
@Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
@Override
public void onStop() {
super.onStop();
Branch.getInstance().logout();
}
//branch io
在我的片段中,我正在生成我分享的推荐链接
BranchUniversalObject branchUniversalObject = new BranchUniversalObject()
.setCanonicalIdentifier("item/12345")
.setTitle("My Content Title")
.setContentDescription("My Content Description")
.setContentImageUrl("https://example.com/mycontent-12345.png")
.setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
.addContentMetadata("property1", "blue")
.addContentMetadata("property2", "red");
LinkProperties linkProperties = new LinkProperties()
.setChannel("facebook")
.setFeature("referral")
.addControlParameter("$android_url", "http://hkpsourcing.com/vidcoin/app-release.apk");
branchUniversalObject.generateShortUrl(getActivity(), linkProperties, new Branch.BranchLinkCreateListener() {
@Override
public void onLinkCreate(String url, BranchError error) {
if (error == null) {
Log.i("MyApp", "got my Branch link to share: " + url);
refUrl=url;
}
}
});
我为推荐人和推介用户制定了规则但是当用户使用推介链接安装应用时,它不会跟踪推荐他的有影响力的人。
答案 0 :(得分:0)
如果您在同一台设备上进行测试,则需要enable debug mode才能触发全新安装。否则,Branch会检测到该应用先前已安装在设备上,而是将其视为for (int i : someArray) {
// for simplicity pretend that all the values
// in someArray are all valid keys for the FOOS hashmap
System.out.println(Foo.FOOS.get(i).id);
}
事件以防止欺诈。