Android Question [solved] Firebase AppInvites

DonManfred

Expert
Licensed User
Longtime User
I am creating this thread because i am writing a wrap for the Firebase AppInvites and i need some help.

Hopefully one of you know the answer.

In the moment i stuck finding the right import to use in #additionaljar for the Firebase DynamicLinks

Logger verbunden mit: 9885e6514556383552
--------- beginning of crash
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
#-Activity_Resume
x53, iStart.Action=android.intent.action.MAIN
x54, iStart.ExtrasToString=no extras
#-Button1_Click
** Activity (main) Pause, UserClosed = false **
** Activity (prepmessage) Create, isFirst = true **
prepmessage_activity_create (java line: 343)
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/dynamiclinks/FirebaseDynamicLinks;
at de.donmanfred.FirebaseDynamicLinkswrapper.Initialize(FirebaseDynamicLinkswrapper.java:44)
at b4a.example.fibainv.prepmessage._activity_create(prepmessage.java:343)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at b4a.example.fibainv.prepmessage.afterFirstLayout(prepmessage.java:102)
at b4a.example.fibainv.prepmessage.access$000(prepmessage.java:17)
at b4a.example.fibainv.prepmessage$WaitForLayout.run(prepmessage.java:80)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.dynamiclinks.FirebaseDynamicLinks" on path: DexPathList[[zip file "/data/app/b4a.example.fibainv-1/base.apk"],nativeLibraryDirectories=[/data/app/b4a.example.fibainv-1/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 14 more

The 1st version of the lib is attached including a example project.

If anyone have a hint what i should use in the #additionalar: please share
 
Last edited:

fredo

Well-Known Member
Licensed User
Longtime User
Nice.
B4X:
#-PrepMessage.btnSend_Click
#-  x67a, DeepLink=https://yourapp.com?utm_content=content&utm_campaign=campaign&at=AffiliateId&ct=CampaignToken&pt=ProviderToken&sd=description&si=imageUrl&st=title&afl=http%3A%2F%2Ffallback&amv=1&apn=b4a.example.fibainv&ibi=unknownparameter&ifl=fallbackurl&imv=1&isi=appstoreID&ius=customscheme&ipbi=ipadBundleId&ipfl=iPadFallbackurl&utm_term=term&utm_medium=medium&utm_source=source
#-  x67a, Authority=yourapp.com
#-  x67a, EncodedAuthority=yourapp.com
#-  x67a, EncodedFragment=null
#-  x67a, EncodedPath=
#-  x67a, EncodedQuery=utm_content=content&utm_campaign=campaign&at=AffiliateId&ct=CampaignToken&pt=ProviderToken&sd=description&si=imageUrl&st=title&afl=http%3A%2F%2Ffallback&amv=1&apn=b4a.example.fibainv&ibi=unknownparameter&ifl=fallbackurl&imv=1&isi=appstoreID&ius=customscheme&ipbi=ipadBundleId&ipfl=iPadFallbackurl&utm_term=term&utm_medium=medium&utm_source=source
#-  x67a, EncodedSchemeSpecificPart=//yourapp.com?utm_content=content&utm_campaign=campaign&at=AffiliateId&ct=CampaignToken&pt=ProviderToken&sd=description&si=imageUrl&st=title&afl=http%3A%2F%2Ffallback&amv=1&apn=b4a.example.fibainv&ibi=unknownparameter&ifl=fallbackurl&imv=1&isi=appstoreID&ius=customscheme&ipbi=ipadBundleId&ipfl=iPadFallbackurl&utm_term=term&utm_medium=medium&utm_source=source
#-  x67a, EncodedUserInfo=null
#-  x67a, Fragment=null
#-  x67a, Host=yourapp.com
#-  x67a, LastPathSegment=null
#-  x67a, Path=
#-  x67a, Query=utm_content=content&utm_campaign=campaign&at=AffiliateId&ct=CampaignToken&pt=ProviderToken&sd=description&si=imageUrl&st=title&afl=http://fallback&amv=1&apn=b4a.example.fibainv&ibi=unknownparameter&ifl=fallbackurl&imv=1&isi=appstoreID&ius=customscheme&ipbi=ipadBundleId&ipfl=iPadFallbackurl&utm_term=term&utm_medium=medium&utm_source=source

#-  x72, trying fbdl.buildShortDynamicLink

#-fbdl_onComplete
#-  x67c, task beendet
#-  x67c, Reloaded

#-fbdl_onFailure

B4X:
' Another look at the Deeplink result
DeepLink=https://yourapp.com
            ?utm_content=content
            &utm_campaign=campaign
            &at=AffiliateId
            &ct=CampaignToken
            &pt=ProviderToken
            &sd=description
            &si=imageUrl
            &st=title
            &afl=http%3A%2F%2Ffallback
            &amv=1
            &apn=b4a.example.fibainv
            &ibi=unknownparameter
            &ifl=fallbackurl
            &imv=1
            &isi=appstoreID
            &ius=customscheme
            &ipbi=ipadBundleId
            &ipfl=iPadFallbackurl
            &utm_term=term
            &utm_medium=medium
            &utm_source=source

Now for the "#-fbdl_onFailure"
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
For the new Invitation feature you need to add one or both of these lines
B4X:
#additionaljar: com.google.firebase:firebase-invites
#AdditionalJar: com.google.firebase:firebase-appindexing

and then in the invite activity on button click

B4X:
    invite.Initialize("","Einladung")
    invite.DeepLink = dynlink.UriStr
    invite.Message = "Dies ist eine Einladung"
    invite.CallToActionText = "TestInvite"
    invite.build

I choosed one contact (me) using SMS... It does work. I got a SMS with a short url....
But then it crashes

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
x52, Main.Activity_Resume
x53, iStart.Action=android.intent.action.MAIN
x54, iStart.ExtrasToString=no extras
#-Main.Button1_Click
** Activity (main) Pause, UserClosed = false **
** Activity (prepmessage) Create, isFirst = true **
** Activity (prepmessage) Resume **
** Activity (prepmessage) Pause, UserClosed = false **
** Activity (prepmessage) Resume **
#-PrepMessage.btnSend_Click
#- x67, strDynamicLink={DeepLink=https://t62hm.app.goo.gl?sd=descrip...nk=https://fbdl.basic4android.de/secure/test/, Authority=t62hm.app.goo.gl, EncodedAuthority=t62hm.app.goo.gl, EncodedFragment=null, EncodedPath=, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedUserInfo=null, Fragment=null, Host=t62hm.app.goo.gl, LastPathSegment=null, Path=, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/}
#- x67a, DeepLink=https://t62hm.app.goo.gl?sd=descrip...nk=https://fbdl.basic4android.de/secure/test/
#- x67a, Authority=t62hm.app.goo.gl
#- x67a, EncodedAuthority=t62hm.app.goo.gl
#- x67a, EncodedFragment=null
#- x67a, EncodedPath=
#- x67a, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F
#- x67a, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F
#- x67a, EncodedUserInfo=null
#- x67a, Fragment=null
#- x67a, Host=t62hm.app.goo.gl
#- x67a, LastPathSegment=null
#- x67a, Path=
#- x67a, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/
** Activity (prepmessage) Pause, UserClosed = false **
sending message to waiting queue (fbdl_oncomplete)
sending message to waiting queue (fbdl_onfailure)
sending message to waiting queue (OnActivityResult)
running waiting messages (3)
#-fbdl_onComplete
#- x67c, task beendet
Reloaded
prepmessage$ResumableSub_fbdl_onCompleteresume (java line: 474)
com.google.android.gms.tasks.RuntimeExecutionException: com.google.android.gms.common.api.ApiException: Forbidden
at com.google.android.gms.tasks.zzn.getResult(Unknown Source)
at de.donmanfred.FirebaseDynamicLinkswrapper.getresult(FirebaseDynamicLinkswrapper.java:132)
at de.basic4android.fbdl.prepmessage$ResumableSub_fbdl_onComplete.resume(prepmessage.java:474)
at de.basic4android.fbdl.prepmessage._fbdl_oncomplete(prepmessage.java:411)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at anywheresoftware.b4a.BA.setActivityPaused(BA.java:432)
at de.basic4android.fbdl.prepmessage$ResumeMessage.run(prepmessage.java:300)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: com.google.android.gms.common.api.ApiException: Forbidden
at com.google.android.gms.internal.zzber.zza(Unknown Source)
at com.google.android.gms.internal.zp.zza(Unknown Source)
at com.google.android.gms.internal.zu.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:573)
*** Service (starter) Create ***
** Service (starter) Start **
START STARTER
Locale not found: de. Switching to 'en'.
Device locale: en
Found 32 strings.
** Service (s1) Create **
** Service (s1) Start **
Bundle[{format=3gpp, pdus=[[B@be47f85, slot=0, phone=0, subscription=1}]
[Address=+49xxxxxxxxxx, Body=Dies ist eine Einladung [url]https://t62hm.app.goo.gl/i/Y1vl5[/url], IsInitialized=false
]
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
network,gps
D1505631000541
*** Service (firebasemessaging) Create ***
INIT
** Service (firebasemessaging) Start **
************fm_Tokenrefresh is ready at this point...
token= cMZC2EDqAZc:APA91bF_LnwllOFvACsHHMEzuLbVdfUAzc0nJAYr7QUY_CZ-QEAA04teY0hTlfTPfDt865DZthjoaEOPJw1Sm_Tpz1Z_TQkymcMdvQEVKhbsXW9A0Yczwq09WqP-vnTGE-FtBo4QvRKq
send1
Raising.. mysql_status
Connected to Database
lib:executeasync()
MySqlStatus:truefalse0
(MyMap) {ms=27, TaskID=httpdata}
aggiornato
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Another try with an email (and updated lib in the meantime)

Logger verbunden mit: 9885e6514556383552
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
x52, Main.Activity_Resume
x53, iStart.Action=android.intent.action.MAIN
x54, iStart.ExtrasToString=no extras
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
x52, Main.Activity_Resume
x53, iStart.Action=android.intent.action.MAIN
x54, iStart.ExtrasToString=no extras
#-Main.Button1_Click
** Activity (main) Pause, UserClosed = false **
** Activity (prepmessage) Create, isFirst = true **
** Activity (prepmessage) Resume **
#-PrepMessage.btnSend_Click
#- x67, strDynamicLink={DeepLink=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/, Authority=t62hm.app.goo.gl, EncodedAuthority=t62hm.app.goo.gl, EncodedFragment=null, EncodedPath=, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedUserInfo=null, Fragment=null, Host=t62hm.app.goo.gl, LastPathSegment=null, Path=, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/}
#- x67a, DeepLink=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/
#- x67a, Authority=t62hm.app.goo.gl
#- x67a, EncodedAuthority=t62hm.app.goo.gl
#- x67a, EncodedFragment=null
#- x67a, EncodedPath=
#- x67a, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F
#- x67a, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F
#- x67a, EncodedUserInfo=null
#- x67a, Fragment=null
#- x67a, Host=t62hm.app.goo.gl
#- x67a, LastPathSegment=null
#- x67a, Path=
#- x67a, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/
** Activity (prepmessage) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
ResultArrived(-1)
ResultArrived()
** Activity (prepmessage) Resume **
Invite_onInvite([888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415])

Please note the new code used in PrepMessage:

B4X:
    ToastMessageShow("Message sent", True)

    invite.Initialize("Invite","Einladung")
    invite.DeepLink = dynlink.UriStr
    invite.Message = cs.Initialize.Typeface(Typeface.FONTAWESOME).Color(0xFF01FF20).Size(40).Append(Chr(0xF17B) & " Einladung " & Chr(0xF17B)).PopAll
    invite.CallToActionText = cs.Initialize.Typeface(Typeface.FONTAWESOME).Color(0xFF01FF20).Size(40).Append(Chr(0xF17B) & " Einladung " & Chr(0xF17B)).PopAll
    invite.build

End Sub
Sub Invite_onInvite(invites As List)
    Log($"Invite_onInvite(${invites})"$)
End Sub

The eMail arrived has a Link inside

Install this Application
https://t62hm.app.goo.gl/i/888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415

For sure it will not reach any valid app on Playstore as my app is not yet published.

But it seems to work :)

Please find updated Lib V0.15 on #1
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I tried to click the link in Android in my eMail-Client... The app crashes :D
Ok, build some checks, getting Bundle data from the Intent, figuring out....

Note that i clicked the Link in the eMail.
for about 10-20 seconds i got shown this

Screenshot_20170917-100243.png



But then the app get started....

The latest results :

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
#- intent0, Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=de.basic4android.fbdl/.main launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
#- intent1, sleep(100)
** Activity (main) Resume **
x52, Main.Activity_Resume
x53, iStart.Action=android.intent.action.MAIN
x54, iStart.ExtrasToString=no extras
#- intent1, sleep(100)
PendingDynamicLinkData result is null
#- intent2, task beendet
InviteMap: null
x28, DeepLinkActivity.Activity_Resume
x29, iStart.Action=android.intent.action.MAIN
x31, getBundleFromIntent=no extras
** Activity (main) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
#- intent0, Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] dat=https://t62hm.app.goo.gl/... flg=0x10880000 pkg=de.basic4android.fbdl cmp=de.basic4android.fbdl/.main launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }
#- intent1, sleep(100)
** Activity (main) Resume **
x52, Main.Activity_Resume
x53, iStart.Action=android.intent.action.MAIN
x54, iStart.ExtrasToString=Bundle[{com.google.android.gms.appinvite.REFERRAL_BUNDLE=Bundle[{com.google.android.gms.appinvite.DEEP_LINK=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/, com.google.android.gms.appinvite.INVITATION_ID=888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415, com.google.android.gms.appinvite.OPENED_FROM_PLAY_STORE=false}]}]
fbdl_onBundleInfo({com.google.android.gms.appinvite.REFERRAL_BUNDLE=null})
#- intent1, sleep(100)
#- intent1, sleep(100)
fbdl_onDynamicLink({Clicktimestamp=1505637506854, UpdateAppIntent=null, Authority=t62hm.app.goo.gl, EncodedAuthority=t62hm.app.goo.gl, EncodedFragment=null, EncodedPath=, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedUserInfo=null, Fragment=null, Host=t62hm.app.goo.gl, LastPathSegment=null, Path=, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/})
#- intent2, task beendet
InviteMap: (MyMap) {com.google.android.gms.appinvite.REFERRAL_BUNDLE=Bundle[{com.google.android.gms.appinvite.DEEP_LINK=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/, com.google.android.gms.appinvite.INVITATION_ID=888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415, com.google.android.gms.appinvite.OPENED_FROM_PLAY_STORE=false}]}
x28, DeepLinkActivity.Activity_Resume
x29, iStart.Action=android.intent.action.MAIN
x31, getBundleFromIntent=Bundle[{com.google.android.gms.appinvite.REFERRAL_BUNDLE=Bundle[{com.google.android.gms.appinvite.DEEP_LINK=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/, com.google.android.gms.appinvite.INVITATION_ID=888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415, com.google.android.gms.appinvite.OPENED_FROM_PLAY_STORE=false}]}]

What should i say? I like to say

3f84003.jpg


The interesting lines are

fbdl_onDynamicLink({Clicktimestamp=1505637506854, UpdateAppIntent=null, Authority=t62hm.app.goo.gl, EncodedAuthority=t62hm.app.goo.gl, EncodedFragment=null, EncodedPath=, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedUserInfo=null, Fragment=null, Host=t62hm.app.goo.gl, LastPathSegment=null, Path=, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/})
The event fbdl_onDynamicLink gets a Map which is printed here to the log

and

#- intent2, task beendet
InviteMap: (MyMap) {com.google.android.gms.appinvite.REFERRAL_BUNDLE=Bundle[{com.google.android.gms.appinvite.DEEP_LINK=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/, com.google.android.gms.appinvite.INVITATION_ID=888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415, com.google.android.gms.appinvite.OPENED_FROM_PLAY_STORE=false}]}

The resulting Map can be optimized :)
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Latest result

B4X:
InviteMap: (MyMap) {DEEP_LINK=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, INVITATION_ID=888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415, OPENED_FROM_PLAY_STORE=false}

Looks good :D

INVITATION_ID=888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415 is the same as i got after i sent the invitation... At this point i need to store the ID (which i did not) to be able to recognize the ID later when someone opened my app from a Invitationlink....

I like it
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
My results are giving me some informations on how we need to care about all.

- At the time we are generating the Invitation we know what parameters we used inside the parameters. We need to save them for later reference. I suggest a database or so....
- After the invitation we get a result with one or more (it is a List) invitation-IDs. We need to same them for later reference. we should save a reference to the parameters we saved in the first step. In my example i got the ID 888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415
- When the app gets started by a referal-link we need to check the invitemap in the Event. Here we found the INVITATION_ID inside the Map. In my case i got 888939569991-fca7b982-a966-4ac6-99c0-eec2c6df2415 (o wonder ;-)).
- Now we can use the INVITATION_ID to check which parameters we saved.
Or we just use the infos given in the Event fbdl_onDynamicLink
fbdl_onDynamicLink({Clicktimestamp=1505637506854, UpdateAppIntent=null, Authority=t62hm.app.goo.gl, EncodedAuthority=t62hm.app.goo.gl, EncodedFragment=null, EncodedPath=, EncodedQuery=sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedSchemeSpecificPart=//t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F, EncodedUserInfo=null, Fragment=null, Host=t62hm.app.goo.gl, LastPathSegment=null, Path=, Query=sd=description&si=imageUrl&st=title&link=https://fbdl.basic4android.de/secure/test/})


Code used to check the intent in activity_create of the main activity

B4X:
    Activity.LoadLayout("Layout1")
    fbdl.Initialize("fbdl")
    Dim iStart As Intent = Activity.GetStartingIntent
    Log($"#-  intent0, ${iStart}"$)
    edtlog.Text = edtlog.Text&CRLF&iStart      
    If iStart <> Null Then
        Dim task As JavaObject = fbdl.getDynamicLinkFromIntent(iStart)
        Do While task.RunMethod("isComplete", Null) = False
            Log($"#-  intent1, sleep(100)"$)
            edtlog.Text = edtlog.Text&CRLF&"sleep"
            Sleep(100)
        Loop
        Log($"#-  intent2, task beendet"$)
      
        Dim invitemap As Map = fbdl.getBundleFromIntent(iStart) ' This is the interesting line. and the map returning for sure :D
        Log("InviteMap: "&invitemap)
        edtlog.Text = edtlog.Text&CRLF&iStart.Action
        'edtlog.Text = edtlog.Text&CRLF&iStart.ExtrasToString
        edtlog.Text = edtlog.Text&CRLF&invitemap
  
        If iStart.Action.Trim.Length <> 0 Then
            Log($" "$)
            Log($"  x28, DeepLinkActivity.Activity_Resume"$)
            'Log($"    x29, iStart.Action=${iStart.Action}"$ )
            'Log($"    x31, getBundleFromIntent=${iStart.ExtrasToString}"$ )
          
            ' ...
          
        End If
    End If

And the needed subs

B4X:
Sub fbdl_onBundleInfo(inviteBundle As Map)
    Log($"fbdl_onBundleInfo(${inviteBundle})"$)  
End Sub
Sub fbdl_onDynamicLink(link As Map)
    Log($"fbdl_onDynamicLink(${link})"$)
End Sub

PD: Please find the newest library V0.16 in Post #1
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I did changed something in the lib in the meantime....
I had a deeper look at the Invitationbuilder and extended it.
I also send out a new Invitation to your email, @fredo
Please have the app (see private conversation) installed before starting it from the link.

The app should show something in the edittext. Please copy all and paste it here. I want to see if "Additional Parameters" are beeing transported
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
So far i found no solution for the Build of the short dynamic link.
We could probably use the http-rest api to get it...

But away from that i thought about the invitation id and how to connect them to some setting using an small api....

I ended up in a small php-script and a database behind to store data for a invitation-id and to get the data for a invitationid

The Sender is adding the invitationid together with the returnvalue when inviting someone....

And on the Receiversite (when the app is started by a deeplink then the app can call the same server to get the invitationdata...


{"CodeGiven":"888939569991-41fae34e-f62d-4b6c-a7be-947dc90279cb","Value":"Hello world!"}
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Uddate about the Deeplink´s LINK...

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    fbdl.Initialize("fbdl")
    editInvitevalue.Text = ""
    Dim iStart As Intent = Activity.GetStartingIntent
    Log($"#-  intent0, ${iStart}"$)
    edtlog.Text = edtlog.Text&CRLF&iStart     
    If iStart <> Null Then
        Dim task As JavaObject = fbdl.getDynamicLinkFromIntent(iStart)
        Do While task.RunMethod("isComplete", Null) = False
            Log($"#-  intent1, sleep(100)"$)
            edtlog.Text = edtlog.Text&CRLF&"sleep"
            Sleep(100)
         
        Loop
        Log($"#-  intent2, task beendet"$)
     
        Dim invitemap As Map = fbdl.getBundleFromIntent(iStart)
        If invitemap <> Null Then
            Log("InviteMap: "&invitemap)
            Dim values() = Regex.Split("&",invitemap.Get("DEEP_LINK"))
            For Each val As String In values
                If val.StartsWith("link=") Then
                    Dim link As String = su.DecodeUrl(val.SubString(val.IndexOf2("=",0)+1),"utf8")
                    Log(link)
                    'Log(su.DecodeUrl(link,"utf8"))
                End If
                Log("Value: "&val)
            Next
            Dim code As String = invitemap.Get("INVITATION_ID")
            Dim j As HttpJob
            j.Initialize("",Me)
            j.Download2("https://domain",Array As String("action","getraw","invcode",code,"deviceID",Starter.DeviceID))
            Wait For (j) JobDone(job As HttpJob)
            If job.Success Then
                Log(job.GetString)
                editInvitevalue.Text = job.GetString
                ' {"Beschreibung":"Bla bla bla","PromoCode":"xyz","PromoID":15}
            Else
                Log(job.ErrorMessage)
            End If
            job.Release

            edtlog.Text = edtlog.Text&CRLF&iStart.Action
            edtlog.Text = edtlog.Text&CRLF&invitemap
 
            If iStart.Action.Trim.Length <> 0 Then
                Log($" "$)
                Log($"  x28, DeepLinkActivity.Activity_Resume"$)
                'Log($"    x29, iStart.Action=${iStart.Action}"$ )
                'Log($"    x31, getBundleFromIntent=${iStart.ExtrasToString}"$ )
         
                ' ...
            End If
            If link.Trim <> "" Then
                Dim Intent1 As Intent
                Intent1.Initialize2(link, 0)
                Log("Starte Deeplink-LINK")
                Log(link)
                StartActivity(Intent1)
            End If
        End If
    End If

End Sub

The interesting lines are
B4X:
        Dim invitemap As Map = fbdl.getBundleFromIntent(iStart)
        If invitemap <> Null Then
            Log("InviteMap: "&invitemap)
            Dim values() = Regex.Split("&",invitemap.Get("DEEP_LINK"))
            For Each val As String In values
                If val.StartsWith("link=") Then
                    Dim link As String = su.DecodeUrl(val.SubString(val.IndexOf2("=",0)+1),"utf8")
                    Log(link)
                    'Log(su.DecodeUrl(link,"utf8"))
                End If
                Log("Value: "&val)
            Next

InviteMap: (MyMap) {DEEP_LINK=https://t62hm.app.goo.gl?sd=description&si=imageUrl&st=title&apn=de.basic4android.fbdl&link=https://fbdl.basic4android.de/secure/test/, INVITATION_ID=888939569991-70ee29cb-9f39-4d54-ad48-5c8eac12b1ab, OPENED_FROM_PLAY_STORE=false}
Value: https://t62hm.app.goo.gl?sd=description
Value: si=imageUrl
Value: st=title
Value: apn=de.basic4android.fbdl
https://fbdl.basic4android.de/secure/test/
Value: link=https%3A%2F%2Ffbdl.basic4android.de%2Fsecure%2Ftest%2F

and these lines too
B4X:
            If link.Trim <> "" Then
                Dim Intent1 As Intent
                Intent1.Initialize2(link, 0)
                Log("Starte Deeplink-LINK")
                Log(link)
                StartActivity(Intent1)
            End If

You now get forwarded to the Activity based on the intent-filter in the manifest....

Though i dont think we really need it... But it is the only "direct way" to transport infos to the app using the Deeplink... In form of a LINK (URL) inside the DeepLink.

For me my solution (see my last post) is OK...
But if you want to "handle" the link. Now you know how to do. :)

In fact this is what the documentation tells about the Deeplink. Check it in every activity if the intent contains a Invitebundle, get the deeeplink, handle the results.

https://firebase.google.com/docs/dynamic-links/android/receive?authuser=0

B4X:
FirebaseDynamicLinks.getInstance()
        .getDynamicLink(getIntent())
        .addOnSuccessListener(this, new OnSuccessListener<PendingDynamicLinkData>() {
            @Override
            public void onSuccess(PendingDynamicLinkData pendingDynamicLinkData) {
                // Get deep link from result (may be null if no link is found)
                Uri deepLink = null;
                if (pendingDynamicLinkData != null) {
                    deepLink = pendingDynamicLinkData.getLink();
                }


                // Handle the deep link. For example, open the linked
                // content, or apply promotional credit to the user's
                // account.
                // ...

                // ...
            }
        })

Handle the deep link. For example, open the linked content, or apply promotional credit to the user's account.

This post is about to handle the deeplink :)
 
Last edited:
Upvote 0
Top