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
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
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
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.
For implementing this feature developers need to learn App links. And For implementing this you can use react-native-deep-linking.
I am giving you a little overview, You need to add some XML in the manifest file for android according to your needs and you will handle it using linking.
Related
We have couple of Firebase Dynamic links defined in our native Android application. For the first time users coming from a dynamic link and install the application, we would like to understand which dynamic link they're coming from.
My question is in order to do that, is there any way to fake the Play Store install from the dynamic link ? Because for the testing purposes I need to check which data is coming.
Example :
User clicks dynamic link https://myapp.page.link/qr/?id=123456
Redirected to Play Store
Installs the app and clicks Open from Play Store
Is it possible to know which URI does that Open button passes the app ?
In iOS it's easier to test. When user clicks a dynamic link and goes to App Store, you can run the codebase and install the app. And when app opens it still behaves like it's installed from App Store. But from Android side it doesn't work like that.
Hope it was explanative enough. Looking forward for suggestions.
For those who might be struggling about the same problem, here how I solved it.
First of all even though in the Firebase Dynamic Links Documentation it says that links will survive the Play Store installation process, it is not completely true. Like in my case
User clicks dynamic link https://myapp.page.link/qr/?id=123456
Redirected to Play Store
Installs the app and clicks Open from Play
Store
After the steps above when user opens the app, Firebase dynamic links listener will only get the base landing page which you set from Firebase console. So if you have a link link like this https://myapp.page.link/qr/?id=123456 your query params will get lost !
However it's still possible to understand which deeplink path did user click and install the application. Long story short it's the utmParameters. That variable is a Bundle comes with couple of extras and one of them is utm_campaign key. Which includes your deeplink name. See the code below :
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener(activity) { pendingDynamicLinkData ->
Log.v(
TAG, "pendingDynamicLinkData link : ${pendingDynamicLinkData?.link}" +
"pendingDynamicLinkData utmParameters : ${pendingDynamicLinkData?.utmParameters}"
)
pendingDynamicLinkData?.let {
// Check if it has your desired utm name
if(it.utmParameters.get("utm_campaign") == "Your Dynamic Link Name") {
//Do the job
}
}
}
.addOnFailureListener(this) { e -> Log.v(TAG, "getDynamicLink:onFailure $e") }
After the implementation, you can create an internal release for yourself and test the download flow from the Play Store.
If I install the app when clicking the dynamic link. All of that information from dynamic should be still available when I open the app for the first time.How can I get that information? It is not working when I use this: getInitialLink() returns Promise<string|null>;
Since, you haven't mentioned - I'm assuming you are having problems with shorter urls, if that's the case try putting the longer url.
Or refer here on Simon's answer: When I use the long instead of short links, everything works perfectly fine.
On Android, you use the getInvitation() method to get data from the Dynamic Link:
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, false).setResultCallback
(/* ... */);
Then, in the callback, you can get the data passed in the Dynamic Links link parameter by calling the getDeepLink() method:
Firebase Documentation - Use Case
For future reference or detailed answer on Firebase Dynamic Links
Behave just like normal Links
In cases where the application doesn’t require installation (say, if it’s already installed) then clicking the Dynamic Link will automatically open the link to the desired screen.
Dynamic Links have a very simple process flow:
The user begins by clicking the Dynamic Link
If the the needs of the Dynamic Link target are satisfied (this is, the application being installed) then the user is navigated to the target location
Otherwise, if the application requires install in order to navigate
to the Dynamic Link target, the the user is taken to the point of
install for the application. Once the application has been installed,
the user is navigated to the target location of the Dynamic Link
And if that wasn’t all, we can integrate Dynamic Links with Firebase Analytics to track the interaction with any links that we generate for our applications. But if we only require simple tracking, then we can use the automatic built-in analytics from the Dynamic Links panel within the Firebase Console where we can also obtain attribution and referrer information for interacted links with no extra effort required from our side.
What makes it different from Google Analytics?
One of the first things that came to my mind when I read about Firebase Analytics was, “What about my Google Analytics setup?”. So if you already have Google Analytics in place, then why would you make the switch to Firebase Analytics? Well, here’s a couple of differences between the two:
Audiences
We can use Firebase Analytics to create Audiences — these are groups of users that we can then interact with using other Firebase service such as Firebase Notifications and / or Firebase Remote Config.
Integration with other Firebase Services
An awesome thing with Firebase Analytics is that we can integrate other Firebase services with analytics. For example, creating an Audience of users who have experienced a crash reported through Firebase Crash Reporting.
Lower Method Count
The Google Analytics dependency on Android has a total count of 18,607 methods and has a total of 4kb used for dependancies. On the other hand, Firebase Core (for Analytics) has a method count of 15,130 and only 1kb used for dependancies.
Automatic Tracking
When we add the firebase core dependency, it will automatically begin tracking a collection of user engagement events and device information for us — this is useful if you’re looking to only collect the minimal data for your app.
Unlimited Reporting
For up to 500 events, Firebase Analytics provides us with unlimited reporting straight out of the box for free!
No Singleton Initialisation
When setting up Google Analytics on Android we are required to initialize a Singleton instance. Firebase Analytics are simply available by fetching the instance directly from where we wish to track data. This isn’t much effort obviously but just makes the setup flow slightly easier.
Single Console
All of the data for every Firebase service is available for a single console. That makes it both easier and quicker for us to navigate from checking the analytic stats for our app to viewing the latest crash reports.
It looks like this is a react-native-firebase open bug for android
For fix the only thing that is required to be changed in module code:
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
return FirebaseAppInvite.getInvitation(pendingDynamicLinkData) != null;
}
to
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(pendingDynamicLinkData);
if (invite != null && invite.getInvitationId() != null && !invite.getInvitationId().isEmpty()) {
return true;
}
return false;
}
Bug reference : https://github.com/invertase/react-native-firebase/issues/1273
Please Check Your Manifest file
open AndroidManifest.file => In your activity tag there is intent-filter tag put below line in that tag.
<data android:scheme="https" android:host="your.dynamic.link" />
<data android:scheme="http" android:host="your.dynamic.link" />
If already done then check this link for the full blog on the dynamic link with react native.
Link: http://blog.logicwind.com/react-native-dynamic-links-using-firebase/
I hope this will help. sorry for the typos.
Let's say I have 4 apps, "Uber Clone" for iOS and Android and "Uber Driver Clone" for iOS and Android. I am using the same Firebase project for all 4 since they share the same database.
When it comes to Facebook Auth though, I can only add a single Facebook app to Firebase. And for every Facebook App I can only add a single iOS and a single Android app. Therefore how can I make this work?
Firebasers, any recommendation/solution in mind?
Multiple apps on a single Facebook app
Go to your Facebook developer console
Go to your app's page
Go to the basic settings
Add all relevant bundle IDs
Here's the key: Add a different URL Scheme suffix for each app. This differentiates each iOS app under your single Facebook App.
In each of your apps info.plist add the suffix information (Make sure both the URL scheme is updated and the "FacebookURLSchemeSuffix" is added!)
Now each of your apps is under the same Facebook App, and thus can register under the same Firebase Realtime Database. Check this out for more info: Two iOS apps using the same Facebook app ID - is it possible?
At this point in time, it does not seem possible to have multiple FB apps under a single Firebase Realtime Database.
A single Facebook App is allowed to connect to multiple iOS apps and multiple Android apps.
For iOS apps, you can specify multiple Bundle ID at Facebook App settings page.
Taken you're using Firebase for authentication, I presume you're using either Real Time Database or Cloud Firestore to store user data as well.
In your user data model, you can add user types.
For example,
user_type : "driver"
Then query users like so:
DBreference.collection("users").whereField("user_type", isEqualTo: "driver").getDocuments() {(querySnapshot, error) in
if error != nil { print(error.debugDescription)
return
}
else if let users = querySnapshot.documents {
for user in users {
guard let userType = user.data()["user_type"] as? String else { return }
print(userType)
}
}
}
This way you don't have to create multiple Facebook apps. Just use the one you have and segment users and their priviliges accordingly.
For example, upon login on both apps, do a check, whether the is user trying to log in as a driver or a passenger.
if currentUser.userType != "passenger" {
print("You can't log into the passanger app with your driver's account.")
}
Hope this helps.
Currently I'm working on user registration form which uses email confirmation.
I've managed to start my app using link in the email, but I have no clue on getting the link which user clicked to start my app.
The link is somewhat like this :
www.lalala.com/CfmEmail?Token=12345&code=ASDfghJKLzxc&Email=kevin#gmail.com
I want to break it down to get its individual value like
Token = 12345, Email = kevin#gmail.com and Code = ASDfghJKLzxc
Please do notify me for any further essential information..
It's known as deep linking. For implementation check developer.android.com
I am using facebook sdk in my app for tracking of ads and install counts. Is there any way to know whether the source of new app install is facebook ad or not.
I read facebook sdk documentation but couldn't find a direct way to do it.
Facebook's mobile app install ads support deep linking. You can use that to send install attribution data into the app. This answer explains how.
I helped build and actively maintain a free deep linking platform called branch.io that can do this very easily for both Android or iOS. The tool leverages a public API that Facebook has to check if a new device came from a Facebook ad, app invite or whatever. You can read more about this public API here.
Let me explain how to set up and use it.
Head to dashboard.branch.io and create a Branch link. Add in labels for campaign, channel, etc depending on your use case. If you want to stuff custom parameters in, you can add unlimited keys/values in the deep link data section at the bottom.
Here's what it would look like: https://bnc.lt/m/3vk4ENnQcm
Once you have your Branch link, you're ready to make an advertisement. While creating your advertisement, you simply need to paste the link into the 'Deep Link' field as in the screenshot below.
Lastly, you want to know client side (after install) if the user came from an advertisement or not. To do this, you simply make a call to the Branch library in your App Delegate for iOS or splash Activity in Android. The callback block in the below example will contain all of the parameters of the link you created on the dashboard.
Branch *branch = [Branch getInstance];
[branch initSessionWithLaunchOptions:launchOptions
andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
if (!error) {
NSLog(#"finished init with deep link params = %#", [params description]);
}
}];
I hope this helps!