Android Question Facebook SDK and Meta Developer

Tomas Petrus

Active Member
Licensed User
Longtime User
Hey guys,
one client for their marketing campaing requested following to be implemented in the B4A and B4i app:

Meta SDK setup in the app
  • Implementing Facebook SDK into the app
  • Configuring events so we can target installations and measure them
Creating an app for iOS and Android in Meta Developer
  • Creating and connecting it to our Business Manager

I couldn't find anything regarding this topic on the forum.
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
I saw this but its about facebook auth. But that is not needed.

I think that
What they want is to measure app installs through facebook campaigns - so measure install events through facebook SDK so they can analyze success rate of different marketing facebook camaigns

CHAT GPT told me this:

Setting up Facebook SDK in B4X (for both Android and iOS)

1. Add the Facebook SDK to your B4A and B4i Projects
For B4A (Android) and B4i (iOS), you'll need to use B4X libraries that integrate the Facebook SDK.

For B4A (Android):
  1. Add Facebook SDK to B4A:
    • Download the Facebook SDK for Android (if not already available in your B4A environment).
    • Use Facebook SDK libraries available for B4A or you can manually add Facebook SDK .jar files to the Libraries folder.
  2. Add Facebook Initialization:
    • Initialize the Facebook SDK in the Main Activity:
    • b4a
      B4X:
      'Add Facebook SDK to your project using the libraries
      Dim fb As Facebook
      fb.Initialize
  3. Track Events (App Install):
    • In B4A, track the app installation using Facebook's AppEvents API:
    • b4a
      B4X:
      fb.AppEventsLogger_logEvent("app_install_event")

For B4i (iOS):

  1. Add Facebook SDK to B4i:
    • In B4i, add Facebook SDK as an external library via CocoaPods or manually. Facebook has an official CocoaPod for iOS SDK integration.
    • For B4i, use B4iBridge and CocoaPods integration to pull the Facebook SDK.
  2. Add Initialization in AppDelegate(via B4i):
    • For iOS, Facebook SDK should be initialized in the app’s delegate:
    • b4i
      B4X:
      #If iOS
      Dim fb As Facebook
      fb.Initialize
      #End If
  3. Track Events (App Install):
    • Use the Facebook API to log events:
    • b4i
      B4X:
      fb.AppEventsLogger_logEvent("app_install_event")

Is he correct right does he miss anything ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Completely wrong.


If you add the Facebook library with the required manifest snippet, then it will start logging events automatically (call Facebook.Initialize).

You can see it with:
B4X:
Dim sdk As JavaObject
    sdk.InitializeStatic("com.facebook.FacebookSdk")
Log(sdk.RunMethod("getAutoLogAppEventsEnabled", Null)

I'm not sure whether it tracks installations. You need to test it.
 
Upvote 0

Tomas Petrus

Active Member
Licensed User
Longtime User
For B4i there is internal iFacebook library - so can I use this ?
For Android there is no internal library So I have to use SDK ? as described here: ?

Erel said:
Download Facebook SDK: https://developers.facebook.com/docs/android/
Find a file named facebook-android-sdk-xx.xx.xx.aar in the SDK.

You need to rename it to: facebook-android-sdk.aar and copy it to the additional libraries folder.

You should create a facebook app with an Android platform:
source: https://www.b4x.com/android/forum/t...seauth-to-support-facebook.67954/#post-430482

Where do I find the required snippet for this use ?

Thank you
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top