Khalifa Alkhatri
Khalifa Alkhatri

Reputation: 294

Flutter dynamic links test

Edited Question :

I have an issue with Firebase Dynamic Links Packag , My goal is getting know if new user installed and opend my app for first time to give him a rewards like 10 point . I tried to search everywhere but no answer,in firebase website there is option to know if user install for first time.

My Goal is : Getting value for first time install & how to debug this code ?

initDynamicLinks when app Lanched :

  void initDynamicLinks() async {
    FirebaseDynamicLinks.instance.onLink(
      onSuccess: (PendingDynamicLinkData dynamicLink) async {
        final Uri deepLink = dynamicLink?.link;

        if (deepLink != null) {
          Navigator.pushNamed(context, deepLink.path);
        }
      },
      onError: (OnLinkErrorException e) async {
        print('onLinkError');
        print(e.message);
      }
    );
    
    final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
    final Uri deepLink = data?.link;

    if (deepLink != null) {
      Navigator.pushNamed(context, deepLink.path);
    }
  }
  .

Upvotes: 0

Views: 1755

Answers (3)

FDuhen
FDuhen

Reputation: 4816

You're mixing two things here.

  • The First-opens tab gives you the number of unique users who clicked on your Firebase Dynamic Link for the first time.

  • If you want to know how many unique users used your app, by clicking the Firebase Dynamic Link or not to get to your app, you have to implement the Firebase Analytics plugin to your app.

This way you'll get access to Dashboards showing you how many Unique users you have.

EDIT
Reading your comment, looks like your question is not related to your problem.

What you want here is to attribute rewards for users who invited their friends thanks to a referral link.
Since I never implemented this witout a dedicated backend, the only thing I can share is a use-case I used some time ago explaining the logic to follow to implement it.
https://firebase.google.com/docs/dynamic-links/use-cases/rewarded-referral

EDIT 2
The logic explained in the documentation is the following :
1- Generate a Dynamic Link for UserA.
2- UserA sends the Dynamic Link to someone (called UserB).
3- When UserB starts the app from a Dynamic Link, retrieve the referral informations in the app (to retrieve UserA's informations)
4- Call a route on your backend to attribute the reward to UserA (and check if UserB is really a new user in your database).

The point is, you shouldn't manage a referral/referrer relationship on the client's side (it would be way too easily abused/hacked).
It's the job of a backend (or cloud function) to manage this.

Upvotes: 1

Fahmi Sawalha
Fahmi Sawalha

Reputation: 622

To be honest i have never used Firebase Dynamic Links , But if your Goal is to Achieve a first open or login token , you can always use the Sharedpreferences package , in my case iam using it to navigate to different pages passed on the first login value . i think that Sharedpreferences is more reliable and easier than what you are trying to achieve with firebase

UPDATE:

what you actually want to do is make a firebase collection with IMEI numbers , when there is a new IMEI that means a new user , when that IMEI is in your collection that means that the app is not installed for the first time , you can use this package imei_plugin to get IMEI number and store it on firebase

Upvotes: 1

Ian H
Ian H

Reputation: 11

Once you have received the link clickthrough in your app use the google_analytics package to log an event.

Related thread here: Flutter log event with google analytics

Upvotes: 1

Related Questions