firebaseinvites runtime event not firing

I’ve tried a few different approaches and I can’t get this event to fire.

My high-level process…

  1. User clicks the share button in my app

  2. User picks from one or more of their contacts

  3. Invitations are sent

  4. Invitation ID’s are stored in my database

  5. The invitee installs the app using the link to the app store (currently a beta release and the invitee is an approved tester)

  6. The new user opens the app.

  7. This is when I would expect the event below to be triggered. Not alert is shown and adb shows no relevant output.

    – FIREBASE INVITES firebaseInvites = require ( “plugin.firebaseInvites” ) firebaseInvites.init() ------------------------------------ – FIREBASE INVITES EVENT ------------------------------------ Runtime:addEventListener( “firebaseInvites”, function (e) print( “FIREBASE INVITES EVENT FIRED” ) native.showAlert(“Response”, glo.DeepPrintString(e), {“ok”}) local i = e.invitationId if(i ~= nil and i ~= “”) then local url = “http://54.213.63.96/api/UserFriendInvitation?fbInvitationId=” … i … “&newUserId=” … glo.userId print( url ) network.request( url, “GET”, handleInviteAcceptResponse ) end end )

I had the thought that maybe the UI wasn’t available, so I put the event string in a glo variable to display on the registration screen:create. Additionally I tried sending it to my web api to store in SQL.  From what I can surmise, it just never gets fired.

------------------------------------ -- FIREBASE INVITES EVENT ------------------------------------ local function onFirebaseInvites( event ) glo.debugStr = glo.DeepPrintString(event) local url = "http://54.###.##.##/api/Debug?text=" .. glo.DeepPrintString(event) network.request( url, "GET", nil ) end Runtime:addEventListener( "firebaseInvites", onFirebaseInvites )

I am looking into it.

Ok got it working. Please check out the new sample and docs.

https://github.com/scottrules44/firebaseInvites-demo

https://scotth.tech/plugin-firebaseInvites

Importantly you are missing these two pieces

Add this to your build.settings

 android= { useGoogleServicesJson = true, intentFilters = { { actions = { "android.intent.action.VIEW" }, categories ={ "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme = "Insert deepLink name here for all this text, the deep link is the thrid field in function" }, }, }, }, 

 and this

local launchArgs = ... if launchArgs and launchArgs.url then print("Data From Launch") print("--------") print(json.encode(launchArgs)) print("--------") end local function urlListener(event) if event.type == "applicationOpen" and event.url then print("Data From Open") print("--------") print(json.encode(event)) print("--------") end end Runtime:addEventListener( "system", urlListener )

Hey Scott,

  Thank you for all of this. I’ve implemented your changes and I’m still unable to get anything back from Google Play.  The first event fired is always applicationStart.  I’m able to capture the invite ID’s when they are sent out, but they are either not included in the event after install or the applicationOpen event just isn’t firing for some reason.

----------------------------------- -- FIREBASE INVITES ------------------------------------ firebaseInvites = require ( "plugin.firebaseInvites" ) firebaseInvites.init() -- Prints all launch arguments local launchArguments = ... if launchArgs and launchArgs.url then print("Data From Launch") print("--------") print(json.encode(launchArgs)) print("--------") end ------------------------------------ -- SYSTEM EVENTS LISTENER ------------------------------------ local function onSystemEvent( event ) print("\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* EVENT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* " .. event.type) if event.type == "applicationOpen" then -- and event.url glo.DeepPrint(event) end local url = "http://54.###.###.##/api/UserApplicationStatus/updateStatus?userEmail=" if(event.type == "applicationStart") then network.request(url .. glo.userEmail .. "&isRunning=true", "GET", nil ) end if(event.type == "applicationExit") then network.request(url .. glo.userEmail .. "&isRunning=false", "GET", nil ) end end Runtime:addEventListener( "system", onSystemEvent )

Can you post a sample project?

Here’s a small project demonstrating what I’m doing. I haven’t added it to Firebase or anything

http://demo.sirentec.net/Tester.zip

In my actual project, the only time I’ve been able to see the “applicationOpen” event fire is when returning from a Facebook share and the app is in a warm state. It doesn’t fire from a cold state coming from Facebook and it never fires coming from Google Play, regardless of the app state

Even when the event does fire coming from Facebook, it still doesn’t contain any invitation information

action

android.intent.action.MAIN

extras

application_link_type

native

al_applink_data

target_url

fb127555964556252://

extras

fb_app_id

127555964556252

referer_app_link

package

com.facebook.katana

url

fb:///

app_name

Facebook

app_id

-269167652

unit_type

app_launch

this part

firebaseInvites.show(message, title, nil

should be this

firebaseInvites.show(message, title, "Second Test"

Sorry, it is that way in my actual app.  I just sent a zip file with [most of] the actual app to support@coronalabs.com

function loadShareScreen(shareWith) if (shareWith == "Contacts") then local message = "Custom message" local title = "Custom Title" local deepLink = "Second Test" local callToActionText = "Click Here to Get It" customImage = "http://54.213.63.96/AppIcon\_600\_600.png" firebaseInvites.show(message, title, deepLink, callToActionText, customImage, function ( ev ) if (ev.isError == true) then -- print("\*\*\*\*\*\*\*\*FIREBASE ERROR\*\*\*\*\*\*\*\*") -- glo.DeepPrint(ev) else -- print("\*\*\*\*\*\*\*\*FIREBASE\*\*\*\*\*\*\*\*") -- glo.DeepPrint(ev) local ids = "" for key, value in pairs(ev.invitationIds) do ids = ids .. "," .. value end RecordInvitations(ids) end end) end if (shareWith == "Facebook") then facebook.login( facebookListener ) end end

Are you using a debug keystore in your release project on firebase console?  

That could potentially be an issue. I’ve used the same Firebase app throughout development and now in production. The only thing I’ve changed is the SHA fingerprints.  I’m currently using a release keystore both locally and, of course, in my Google Play production release.  If you mean the fingerprints, then yes, they came from the release keystore. 

Otherwise, how do I determine the keystore being used in Firebase?

Can try this code to see if it does anything? I have tested via google play, will try that later

Runtime:addEventListener("firebaseInvites", function() print("test123") end)

I doesn’t do anything.  I do see this in adb, not sure if it’s related.

CoronaRuntimeTaskDispatcher.send() doesn’t have an available CoronaRuntime to run this task on! Abort!

Try rebuilding now.

I’m still not seeing anything. Warm or cold. 

I started digging deeper into the dynamic links in FB and either they don’t appear to be working correctly, or I am just ignorant.

If I Preview (Debug) the dynamic link from Firebase, it looks like this…

https://p43a9.app.goo.gl/?link=http%3A%2F%2F54.213.63.96%2Fapi%2Fuserfriendinvitation&apn=com.balloonknotgames.fartcommander&d=1

If I create a new invite and paste the short link into my browser, it resolves to this…

https://play.google.com/store/apps/details?id=com.balloonknotgames.fartcommander&pcampaignid=appinvite_&referrer=invitation_id%3D377426389920-6baa9726-6113-44d3-83d7-ddd3183e8aaa

It seems to me that the “link” parameter should also be included in the invite link. Unless they are doing something on the backend to fetch and forward to the app?

Then if I go into the Link Preview (Debug) flowchart and click on the “Play Store” links under Have Play Services < 1.1.15 I get this…

https://play.google.com/store/apps/details?id=com.balloonknotgames.fartcommander&pcampaignid=fdl_long&url=http://54.213.63.96/api/userfriendinvitation

So now it has a url parameter that I would expect to see, since we are trying to work with event.url

I have been reading, looks like you have to use a domain. Let do some research. 

The intent filter should catch deep links of your domain, since the Dynamic Link will redirect to your domain if your app is installed. This is required for your app to receive the Dynamic Link data after it is installed from the Play Store.

Try demo

https://www.dropbox.com/s/5om03zyrgcqb44i/Tester.zip?dl=0

Thanks. I tried that earlier today, but I used an IP address instead of a domain. I can’t transfer my DNS record yet because it’s not old enough.  I’ll try a different domain for the time being.

Still not seeing the url come back.  It could be me.  Do you know if a subdomain will work? dev.mydomain.com

try the updated demo

https://www.dropbox.com/s/5om03zyrgcqb44i/Tester.zip?dl=0

and send any output