Firebase Analytics and Push Notifications

Hello Community,

it seems that Scott Techs Firebase Analytics and Corona’s notifications v2 plugin does somehow collide.

If I require and initialize both in main.lua one ot the other does not work anymore.

Is this possible? Maybe some “namespace issues”? (just guessing).

Any idea if there is way to bring both to life?

Thanks in advance
René

You should try using a timer for init each one, for example. Notification init at 100 milliseconds and analytics at 200 milliseconds.

Ok, I will give it a try!

Unfortunately this des not help. I even tried to setup notifications in a scene that is loaded later.

But as soon as firebase analytics is used the registering for remote notifications does not fire.

Maybe any other ideas?

Can you please file a bug report

https://docs.google.com/forms/d/e/1FAIpQLSf-V3z-V3FZ5y9Sb19cxVfjx7fSRV9HIbpAGptN7DaY3Ki_DA/viewform

I have filed a bug report. I added a link to a simple main.lua but of course you would need to prepare your test app for firebase push notifications with your own firebase credentials. 

This has been patched

Hey Scott,

I already mailed you that the problem still occurs on my side.

I have no experience in plugin development, so I don’t know if the following information might be useless to you.

I talked to a someone else who used the iOS Firebase SDK with Corona Native.
He said he had to set FirebaseAppDelegateProxyEnabled type “Boolean” to “NO”. Otherwise the Push Notifications did not work.

Sorry, that informations was useless:
we already use FirebaseAppDelegateProxyEnabled = false in the build.settings.

You made an error in your sample code

firebaseAnalytics.logEvent("test2")

should be

firebaseAnalytics.logEvent("test2", {data="hello world"})

You need to pass a table into the second param

Ok, but even this small example does not work:

local notifications = require('plugin.notifications.v2') local firebaseAnalytics = require( "plugin.firebaseAnalytics" ) firebaseAnalytics.init() local function notificationListener( event ) print('Event:' .. event.type) end Runtime:addEventListener('notification', notificationListener) timer.performWithDelay( 4000, function() notifications.registerForPushNotifications({useFCM=true}) end)

Here I do not even use a logEvent().  If I remove the firebaseAnalytics.init() then the registerForPushNotifications does work (the popup fires). If I do not remove the init() call the popup does not show up.

trying initing after registering

local notifications = require('plugin.notifications.v2') local firebaseAnalytics = require( "plugin.firebaseAnalytics" ) local function notificationListener( event ) print('Event:' .. event.type) end Runtime:addEventListener('notification', notificationListener) timer.performWithDelay( 4000, function() notifications.registerForPushNotifications({useFCM=true}) firebaseAnalytics.init() end)

Ok I can try this. But this will be not useful in most cases.

I already need to log system events like app resume, app suspend, app start and app exit. These events occur at the very beginning of the app life cycle.

Furthermore requesting access for push notifications should be done strategically later in the game.

I will investigate if there is more I can do

That would be great. Thank you for your endurance!

Using Firebase for Analytics and Push Notifications is really an important and powerful tool set!

Just a quick update I have looked into this pretty hard and have not had a lot of luck. Unforchantly corona has not open sourced the notification which would help a lot but I really cannot do anything about this. For the record this what my code objc for init is

[FIRApp configure];

Yep that simple

I think you are going to have better luck corona support or filing a bug report with them.

Thanks,

Scott

Hey Scott,

thank you for looking into this again.

I will ask Corona support on this issue.

Best

René

@Scott and @Rene, did the latest Corona Notifications update in April 2018 resolve this issue?

attempt #2, @Scott and @Rene, did the latest Corona Notifications update in April 2018 resolve this issue?

I am not sure, it should be but I don’t keep track off other developers plugins