3

I'm currently using Firebase 11.2.0 and unable to create a short dynamic link successfully

My code to create the long link is:

val link = "https://example.com/param/id"
val dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
            .setLink(Uri.parse(link))
            .setDynamicLinkDomain("v53sr.app.goo.gl")
            .setAndroidParameters(DynamicLink.AndroidParameters.Builder("com.greelionsoft.mareas.espana")
                    .setMinimumVersion(22)
                    .build())
            .buildDynamicLink()

This long link code can be shared via intent and works as expected but it's way too long.

Then the code to create shortlink:

FirebaseDynamicLinks.getInstance().createDynamicLink()
             .setLongLink(dynamicLink.uri)
             .buildShortDynamicLink()
             .addOnCompleteListener { task ->
                 if (task.isSuccessful) {

                     val shortLink = task.result.shortLink

                     //handle shortlink
                 } else {
                     //handle error
                     Log.e("TAG", "Short Dynamic link error", task.exception)

                 }
             }

Task is always unsuccessful and the following error is printed in logcat:

Dynamic link error 7: Forbidden                                                                        
com.google.android.gms.common.api.ApiException: 7: Forbidden
at com.google.android.gms.common.api.internal.zzde.zza(Unknown Source)
at com.google.android.gms.internal.zzdzo.zza(Unknown Source)
at com.google.android.gms.internal.zzdzt.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:565)

I haven't been able to find any clue about this "Error 7: Forbidden"

Has anybody encountered the same issue?

Thanks.

Pablo A. Martínez
  • 2,547
  • 2
  • 23
  • 28

1 Answers1

7

Finally I solved the problem

1- First add your SHA256 certificate fingerprint to your Firebase Project Configuration

2- Enable "Firebase Dynamic Links API" for your project at console.cloud.google.com console

Enjoy short links!

MertNYuksel
  • 311
  • 1
  • 8
Pablo A. Martínez
  • 2,547
  • 2
  • 23
  • 28
  • How did you do this, I did not see where to enable Firebase Dynamic Link API on Google console? – Val Okafor Sep 11 '17 at 06:01
  • @ValOkafor just log into console.cloud.google.com and use the search box with "Firebase Dynamic Links API" then Enable the api – Pablo A. Martínez Sep 11 '17 at 09:45
  • 1
    Thanks, @Pablo A. Martínez I have enabled the API and still having issues. Please take a look at my question and see if there is anything that I am missing https://stackoverflow.com/questions/46150106/firebase-dynamic-link-shorturl-not-working-in-android – Val Okafor Sep 11 '17 at 14:58