capacitor-community / facebook-login

Facebook Login support
MIT License
103 stars 55 forks source link

App Events Facebook #108

Open cprodhomme opened 2 years ago

cprodhomme commented 2 years ago

Is your feature request related to a problem? Please describe. I want to implement App Events Facebook on my Ionic Capacitor project and use Facebook Login.

Describe the solution you'd like I want to have a function like this library : https://ionicframework.com/docs/native/facebook

.logEvent(MY_EVENT);

Describe alternatives you've considered

Thanks ! 🙏

codeconsole commented 1 year ago

Seems pretty straightforward to implement. Just add a method .logEvent(MY_EVENT);

https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#manually-log-events https://developers.facebook.com/docs/app-events/getting-started-app-events-android#log-manually

codeconsole commented 1 year ago

I am not sure if my app is configured properly because the only Test Events that I receive are

fb_login_dialog_confirm_accept
fb_login_dialog_confirm_impression

and I only receive these on iOS. I don't receive any Test Events on android. (I can't log events using facebookConnectPlugin.logEvent(String name, Object params, Number valueToSum, Function success, Function failure) https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect#log-an-event either so I believe this is a problem with my app).

@cprodhomme perhaps you can give it a try and see if it works for you.

Here is how you can test

git clone https://github.com/codeconsole/facebook-login
cd facebook-login
git checkout app-events

then update your app/package.json to your app to point to the plugin directory:

    "@capacitor-community/facebook-login": "file:../facebook-login",

My directory structure is:

app
facebook-login

Syntax is:

Capacitor.Plugins.FacebookLogin.logEvent({eventName:'BattleTheMonster'})

https://github.com/capacitor-community/facebook-login/pull/112

codeconsole commented 1 year ago

Seems related to my issue https://github.com/SpellChucker/capacitor-plugin-facebook-analytics/issues/4

codeconsole commented 1 year ago

I have determined on iOS, it is version specific. v13.5 works but 15.2 does not work.

Not sure if the following are related: https://developers.facebook.com/docs/audience-network/setting-up/platform-setup/ios/add-sdk/ https://stackoverflow.com/questions/68599825/not-receiving-events-via-facebook-ios-sdk https://developers.facebook.com/docs/app-events/guides/advertising-tracking-enabled/ https://stackoverflow.com/questions/67832203/cannot-find-fbadsettings-isadvertisertrackingenabledtrue https://developers.facebook.com/docs/app-events/getting-started-app-events-ios#add-events

codeconsole commented 1 year ago

I just confirmed Capacitor.Plugins.FacebookLogin.logEvent({eventName:'BattleTheMonster'}) also works with iOS 13.7 devices.

codeconsole commented 1 year ago

https://github.com/facebook/facebook-ios-sdk/issues/1937

codeconsole commented 1 year ago

https://github.com/xamarin/FacebookComponents/issues/228

codeconsole commented 1 year ago

I confirm Android works. The only issue is iOS 14+

https://github.com/facebook/facebook-ios-sdk/issues/2145

codeconsole commented 1 year ago

iOS 14+ works ask long as Allow Tracking is turned on inside the Facebook App of the user signing in regardless of whether or not the Facebook App is installed on the same device running the app.

FernetB commented 1 year ago

Would be amazing if u could add it to the package, I was trying to use https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect on my capacitor project without success, I'm unable to build the app

But It would be nice if you could add logEvent, setUserData and clearUserData

codeconsole commented 1 year ago

@FernetB for logEvent, you can just use my repository for the time being until it is merged.

To use my version instead, just do:

nom install https://github.com/codeconsole/facebook-login#app-events

Looking at the FB developer documentation, I am not seeing anything on setUserData or clearUserData. Are those associated with analytics? That was shut off by FB.

https://www.facebook.com/business/help/966883707418907 https://developers.facebook.com/docs/reference/android/current/class/AppEventsLogger/

FernetB commented 1 year ago

Hey, thanks for the fast response!

I saw that from here https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect#advanced-matching and here https://developers.facebook.com/docs/app-events/advanced-matching/

codeconsole commented 1 year ago

@FernetB

I think it was removed from the API because if you see here https://developers.facebook.com/docs/app-events/advanced-matching/ It shows setUserData is a method of AppEventsLogger, but the links to the documentation for AppEventsLogger are broken.

And of you view the latest documentation https://developers.facebook.com/docs/reference/android/current/class/AppEventsLogger/ there is no setUserData method

gelinger777 commented 1 year ago

@codeconsole do you have idea if automatic app install events will be tracked ? Just wonder if we can use this for it...

marshall86 commented 1 year ago

Is it possible to user the plugin to trace app installations and other events? are there any limitations on ios or android?

trinitiwowka commented 1 year ago

same question. can i use this plugin for tracking app installs ?

Linknpay commented 9 months ago

Please add a second parameter in LogEvent function like this:

logEvent(options: { name: string, params: any })

so we can use it to log all events related to facebook ads

Linknpay commented 9 months ago

@trinitiwowka @marshall86 You can use this freshly new plugin that is compatible with Capacitor 5 https://www.npmjs.com/package/capacitor-facebook-events