-
public class AppEventsLogger.Companion
-
-
Field Summary
Fields Modifier and Type Field Description private final StringACTION_APP_EVENTS_FLUSHEDprivate final StringAPP_EVENTS_EXTRA_NUM_EVENTS_FLUSHEDprivate final StringAPP_EVENTS_EXTRA_FLUSH_RESULTpublic final static AppEventsLogger.CompanionINSTANCE
-
Method Summary
Modifier and Type Method Description final UnitactivateApp(Application application)Notifies the events system that the app has launched and activate and deactivate events should start being logged automatically. final UnitactivateApp(Application application, String applicationId)Notifies the events system that the app has launched and activate and deactivate events should start being logged automatically. final UnitinitializeLib(Context context, String applicationId)Notifies the events system which internal SDK Libraries, and some specific external Libraries that the app is utilizing. final AppEventsLoggernewLogger(Context context)Build an AppEventsLogger instance to log events through. final AppEventsLoggernewLogger(Context context, AccessToken accessToken)Build an AppEventsLogger instance to log events through. final AppEventsLoggernewLogger(Context context, String applicationId, AccessToken accessToken)Build an AppEventsLogger instance to log events through. final AppEventsLoggernewLogger(Context context, String applicationId)Build an AppEventsLogger instance to log events that are attributed to the application but not to any particular Session. final AppEventsLogger.FlushBehaviorgetFlushBehavior()Access the behavior that AppEventsLogger uses to determine when to flush logged events to the server. final UnitsetFlushBehavior(AppEventsLogger.FlushBehavior flushBehavior)Set the behavior that this AppEventsLogger uses to determine when to flush logged events to the server. final UnitonContextStop()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. final UnitsetPushNotificationsRegistrationId(String registrationId)Sets and sends registration id to register the current app for push notifications. final UnitaugmentWebView(WebView webView, Context context)Intended to be used as part of a hybrid webapp. final StringgetUserID()Returns the set user id else null. final UnitsetUserID(String userID)Sets a user id to associate with all app events. final UnitclearUserID()Clears the currently set user id. final UnitsetUserData(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. final StringgetUserData()Returns the set user data else null. final UnitclearUserData()Clears the current user data final StringgetAnonymousAppDeviceGUID(Context context)Each app/device pair gets an GUID that is sent back with App Events and persisted with this app/device pair. final UnitsetInstallReferrer(String referrer)final StringgetACTION_APP_EVENTS_FLUSHED()The action used to indicate that a flush of app events has occurred. final StringgetAPP_EVENTS_EXTRA_NUM_EVENTS_FLUSHED()final StringgetAPP_EVENTS_EXTRA_FLUSH_RESULT()-
-
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 applicationapplicationId- 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 ContextapplicationId- 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 behaviourcontext- 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
-
clearUserID
final Unit clearUserID()
Clears the currently set 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 emailfirstName- user's first namelastName- user's last namephone- user's phonedateOfBirth- user's date of birthgender- user's gendercity- user's citystate- user's statezip- user's zipcountry- user's country
-
getUserData
final String getUserData()
Returns the set user data else null.
-
clearUserData
final Unit clearUserData()
Clears the current user data
-
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.
-
setInstallReferrer
final Unit setInstallReferrer(String referrer)
-
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 [ ].
-
getAPP_EVENTS_EXTRA_NUM_EVENTS_FLUSHED
final String getAPP_EVENTS_EXTRA_NUM_EVENTS_FLUSHED()
-
getAPP_EVENTS_EXTRA_FLUSH_RESULT
final String getAPP_EVENTS_EXTRA_FLUSH_RESULT()
-
-
-
-