推荐计划在安卓 branch.io 不起作用



io为我的安卓应用程序制作推荐程序。我根据此处描述的分支文档进行集成 https://dev.branch.io/getting-started/sdk-integration-guide/guide/android/

并且安装跟踪并向用户提供奖励工作正常,但是如果我使用用户推荐链接进行安装,则 work.it 不会向影响者提供奖励。

这是我的代码

在清单中

<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;
            }
        }
    });

我为推荐人和推荐用户制定了规则,但是当用户使用推荐链接安装应用程序时,它不会跟踪推荐他的影响者。

Alex 来自 Branch.io 这里:

如果要在同一设备上进行测试,则需要启用调试模式才能为此触发全新安装。否则,Branch 会检测到该应用以前已安装在设备上,并将其计为reopen事件以防止欺诈。

最新更新