Package 

Object AppEventsLogger.Companion

    • Method Detail

      • activateApp

         final Unit activateApp(Application application)

        Notifies the events system that the app has launched and activate and deactivate events should start being logged automatically. By default this function is called automatically from sdkInitialize() flow. In case 'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting is set to false, it should typically be called from the OnCreate method of you application.

        Parameters:
        application - The running application
      • activateApp

         final Unit activateApp(Application application, String applicationId)

        Notifies the events system that the app has launched and activate and deactivate events should start being logged automatically. By default this function is called automatically from sdkInitialize() flow. In case 'com.facebook.sdk.AutoLogAppEventsEnabled' manifest setting is set to false, it should typically be called from the OnCreate method of you application.

        Call this if you wish to use a different Application ID then the one specified in the Facebook SDK.

        Parameters:
        application - The running application
        applicationId - The application id used to log activate/deactivate events.
      • initializeLib

         final Unit initializeLib(Context context, String applicationId)

        Notifies the events system which internal SDK Libraries, and some specific external Libraries that the app is utilizing. This is called internally and does NOT need to be called externally.

        Parameters:
        context - The Context
        applicationId - The String applicationId
      • newLogger

         final AppEventsLogger newLogger(Context context)

        Build an AppEventsLogger instance to log events through. The Facebook app that these events are targeted at comes from this application's metadata. The application ID used to log events will be determined from the app ID specified in the package metadata.

        Parameters:
        context - Used to access the applicationId and the attributionId for non-authenticated users.
      • newLogger

         final AppEventsLogger newLogger(Context context, AccessToken accessToken)

        Build an AppEventsLogger instance to log events through.

        Parameters:
        context - Used to access the attributionId for non-authenticated users.
        accessToken - Access token to use for logging events.
      • newLogger

         final AppEventsLogger newLogger(Context context, String applicationId, AccessToken accessToken)

        Build an AppEventsLogger instance to log events through.

        Parameters:
        context - Used to access the attributionId for non-authenticated users.
        applicationId - Explicitly specified Facebook applicationId to log events against.
        accessToken - Access token to use for logging events.
      • newLogger

         final AppEventsLogger newLogger(Context context, String applicationId)

        Build an AppEventsLogger instance to log events that are attributed to the application but not to any particular Session.

        Parameters:
        context - Used to access the attributionId for non-authenticated users.
        applicationId - Explicitly specified Facebook applicationId to log events against.
      • getFlushBehavior

         final AppEventsLogger.FlushBehavior getFlushBehavior()

        Access the behavior that AppEventsLogger uses to determine when to flush logged events to the server. This setting applies to all instances of AppEventsLogger.

      • setFlushBehavior

         final Unit setFlushBehavior(AppEventsLogger.FlushBehavior flushBehavior)

        Set the behavior that this AppEventsLogger uses to determine when to flush logged events to the server. This setting applies to all instances of AppEventsLogger.

        Parameters:
        flushBehavior - the desired behavior.
      • onContextStop

         final Unit onContextStop()

        Call this when the consuming Activity/Fragment receives an onStop() callback in order to persist any outstanding events to disk so they may be flushed at a later time. The next flush (explicit or not) will check for any outstanding events and if present, include them in that flush. Note that this call may trigger an I/O operation on the calling thread. Explicit use of this method is necessary.

      • setPushNotificationsRegistrationId

         final Unit setPushNotificationsRegistrationId(String registrationId)

        Sets and sends registration id to register the current app for push notifications.

        Parameters:
        registrationId - RegistrationId received from FCM.
      • augmentWebView

         final Unit augmentWebView(WebView webView, Context context)

        Intended to be used as part of a hybrid webapp. If you call this method, the FB SDK will add a new JavaScript interface into your webview. If the FB Pixel is used within the webview, and references the app ID of this app, then it will detect the presence of this injected JavaScript object and pass Pixel events back to the FB SDK for logging using the AppEvents framework.

        Parameters:
        webView - The webview to augment with the additional JavaScript behaviour
        context - Used to access the applicationId and the attributionId for non-authenticated users.
      • setUserID

         final Unit setUserID(String userID)

        Sets a user id to associate with all app events. This can be used to associate your own user id with the app events logged from this instance of an application.

        The user ID will be persisted between application instances.

        Parameters:
        userID - A User ID, or null to clear the User ID
      • setUserData

         final Unit setUserData(String email, String firstName, String lastName, String phone, String dateOfBirth, String gender, String city, String state, String zip, String country)

        Sets user data to associate with all app events. All user data are hashed and used to match Facebook user from this instance of an application.

        The user data will be persisted between application instances.

        Parameters:
        email - user's email
        firstName - user's first name
        lastName - user's last name
        phone - user's phone
        dateOfBirth - user's date of birth
        gender - user's gender
        city - user's city
        state - user's state
        zip - user's zip
        country - user's country
      • getAnonymousAppDeviceGUID

         final String getAnonymousAppDeviceGUID(Context context)

        Each app/device pair gets an GUID that is sent back with App Events and persisted with this app/device pair.

        Parameters:
        context - The application context.
      • getACTION_APP_EVENTS_FLUSHED

         final String getACTION_APP_EVENTS_FLUSHED()

        The action used to indicate that a flush of app events has occurred. This should be used as an action in an IntentFilter and BroadcastReceiver registered with the [ ].