android firebase dynamic link PendingDynamicLinkData is null direct through app

You should handle your PendingDynamicLinkData in activity to override onCreate and onNewIntent. Like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        if (intent != null) {
            handleDeepLink(intent);
        }
}

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent != null) {
        handleDeepLink(intent);
    }
}

private void handleDeepLink(Intent intent) {
        FirebaseDynamicLinks.getInstance().getDynamicLink(intent).addOnSuccessListener(pendingDynamicLinkData -> {
            if (pendingDynamicLinkData != null) {
                Uri deepLink = pendingDynamicLinkData.getLink();
                if (deepLink != null) {
                    // todo .....
                }
            }
        });
    }

Leave a Comment