8

我必须在我的 Android 应用程序中实现邀请和赚取功能。

我要做的是:用户可以将链接分享给社交媒体上的任何人,收到链接后,另一个用户可以单击链接以使用该链接安装应用程序。

在用户使用该链接安装应用程序后,发送者或受邀者可以获得奖励。这怎么可能?

到目前为止,我浏览了 Firebase 的动态链接概念并找到了一些演示。但是,还是很迷茫。

您能否指导我实现这一目标还需要经历哪些其他事情?

是否有可能在本机反应中。如果没有,那么我怎样才能在 Android 中实现呢?

谢谢

4

2 回答 2

3

您可以使用react-native-branch在您的反应原生应用程序中集成推荐和赚取

只需遵循在您的 react-native 应用程序中集成branch.io的文档,您就可以开始了。

react-native-branch 的文档

这里也是一个github例子供你参考 Example

于 2018-09-13T10:47:57.560 回答
3

由于您已经经历过firebase,因此您可以轻松使用基于相同的程序。

这是入门的路线图

流程图

设置

  • 按照初始设置指南配置将项目添加到 Firebase
  • 配置android/app/build.gradleMainApplication.java添加firebase动态链接
  • 配置Firebase 邀请包
  • 如果您还没有配置深层链接,请查看本教程

用法

发送邀请组件

import firebase from 'react-native-firebase';

const title = 'Demo Firebase Invites'
const message = 'You have been invite to join the xxxxx app'
const invitation = new firebase.invites.Invitation(title, message);
invitation.setDeepLink(// Your App's Configured deep link)
invitation.setCustomImage(// Image Uri)
invitation.setCallToActionText(// Set the text on the invitation button on the email)

// ... On some button click
sendInvitation = async () => {
  const invitationIds = await firebase.invites().sendInvitation(invitation)
  // Invitation Id's can be used to track additional analytics as you see fit.
}

处理接收邀请

使用getInitialInvitation方法或使用onInvitation侦听器侦听邀请。

在您的应用程序的根目录中,您可以添加

import firebase from 'react-native-firebase';

firebase.invites()
.getInitialInvitation()
.then((invitation) => {
    if (invitation) {
        // app opened from an Invitation
        // Set the rewards points here and update data in your firebase
    } else {
       // app NOT opened from an invitation
       // No rewards for this user
    }
});

邀请包含以下对象,这些对象将帮助您查询有关更新发送者奖励积分的问题。

deepLink: string
invitationId: string

您可以使用深层链接路由到特定页面,还可以获取从受邀者传递的自定义数据,例如随机数据userId以在 firebase 上创建用户。用于invitationId查询其他内容。

于 2018-09-13T16:30:50.667 回答