Skip to content Skip to sidebar Skip to footer

Firebase Dynamic Link New Install Events

I want to get the event of New install or App open/re-open events in my Android App whenever user click on any dynamic link. Following events are captured in Analytics as per docum

Solution 1:

I have found solution to my above question. Sharing details here.

Below code is tested from PlayStore also.

You can get mentioned two events through pendingDynamicLinkData callback object received from addOnSuccessListener.

Complete code to get link and associated Dynamic link data here.

FirebaseDynamicLinks.getInstance()
                .getDynamicLink(getIntent())
                .addOnSuccessListener(this, pendingDynamicLinkData -> {
                    // Get deep link from result (may be null if no link is found)try {
                        Uri deepLink = null;
                        if (pendingDynamicLinkData != null) {
                            deepLink = pendingDynamicLinkData.getLink();

                            sendInstallDetailToAPI(pendingDynamicLinkData.getExtensions());

                        }
                        CgUtils.showLog(TAG, "getDynamicLink:onSuccess" + deepLink);
                    } catch (Exception e) {
                        CgUtils.showLog(TAG, "getDynamicLink:onFailure" + e);
                    }

                })
                .addOnFailureListener(this, e -> CgUtils.showLog(TAG, "getDynamicLink:onFailure" + e));

Below method to send the Dynamic Link data to your backend API if you want.

privatevoidsendInstallDetailToAPI(Bundle deepBundle) {

      
        BundledeepLinkData= deepBundle.getBundle("scionData");
        if (deepLinkData != null) {
            BundleappReOpenBundle= deepLinkData.getBundle("dynamic_link_app_open");
            booleanisInstall=false;
            Stringmedium="", source = "", campaign = "", shortLink = "";
            if (appReOpenBundle != null) {
                medium = appReOpenBundle.getString("medium", "NA");
                source = appReOpenBundle.getString("source", "NA");
                campaign = appReOpenBundle.getString("campaign", "NA");
                shortLink = appReOpenBundle.getString("dynamic_link_link_id", "NA");
            }

            BundleappFirstOpenBundle= deepLinkData.getBundle("dynamic_link_first_open");

            if (appFirstOpenBundle != null) {
                isInstall = true;
                medium = appFirstOpenBundle.getString("medium", "NA");
                source = appFirstOpenBundle.getString("source", "NA");
                campaign = appFirstOpenBundle.getString("campaign", "NA");
                shortLink = appFirstOpenBundle.getString("dynamic_link_link_id", "NA");
            }

        // Send ABOVE detail to your respective APIs


        }
    }

Now If isInstall flag is true that means it's first time open after install else reopen.

Post a Comment for "Firebase Dynamic Link New Install Events"