Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native : Implementing Reward Referral (Invite and Earn)

I have to implement Invite and Earn functionality in my Android application.

What I have to do is : User can share the link to anyone on social media, On receiving the link, another user can click the link to get the application installed using that link.

After the user installs the app using that link, the sender or the invitee can be rewarded. How this can be possible ?

So far, I go through the Firebase's Dynamic Link concepts and found some demo. But, still confused in it.

Can you please guide me what another stuffs I have to gone through to achieve such thing ?

Is it possible in react-native. If not then How can I achieve that in Android ?

Thanks

like image 460
Jaimin Modi Avatar asked Sep 11 '18 07:09

Jaimin Modi


2 Answers

You can Integrate Refer & earn in your react native application using react-native-branch

Just following the documentation of integrating branch.io in your react-native application and you will be good to go.

Documentation for react-native-branch

Here is also a github example for your reference Example

like image 70
Chirag Sharma Avatar answered Oct 04 '22 05:10

Chirag Sharma


Since you have already gone through firebase, therefore it would be easy for you to use the procedure based on the same.

Here's the roadmap for getting started

Flow map

Set Up

  • Follow the Initial Setup Guide to configure adding the project to Firebase
  • Configure the android/app/build.gradle and MainApplication.java to add the firebase dynamic links
  • Configure the Firebase invites package
  • If you haven't configured deep link , take a look at this tutorial

Usage

SendInvitation Component

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.
}

Handle Receive Invitation

Either use getInitialInvitation method or listen for invitations using the onInvitation listener.

At the root of your app you can add

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

The invitation contains the following objects which will help you with the queries on updating the sender reward points.

deepLink: string
invitationId: string

You can route to specific page using the deep link, and also get custom data passed from the invitee such as a random userId to create the user on the firebase. Use invitationId to query other stuff.

like image 39
Pritish Vaidya Avatar answered Oct 04 '22 04:10

Pritish Vaidya