Search in sources :

Example 1 with FetchedAppSettings

use of com.facebook.internal.FetchedAppSettings in project facebook-android-sdk by facebook.

the class FacebookRequestError method getErrorClassification.

static synchronized FacebookRequestErrorClassification getErrorClassification() {
    FacebookRequestErrorClassification errorClassification;
    FetchedAppSettings appSettings = FetchedAppSettingsManager.getAppSettingsWithoutQuery(FacebookSdk.getApplicationId());
    if (appSettings == null) {
        return FacebookRequestErrorClassification.getDefaultErrorClassification();
    }
    return appSettings.getErrorClassification();
}
Also used : FetchedAppSettings(com.facebook.internal.FetchedAppSettings) FacebookRequestErrorClassification(com.facebook.internal.FacebookRequestErrorClassification)

Example 2 with FetchedAppSettings

use of com.facebook.internal.FetchedAppSettings in project facebook-android-sdk by facebook.

the class AppEventQueue method buildRequestForSession.

private static GraphRequest buildRequestForSession(final AccessTokenAppIdPair accessTokenAppId, final SessionEventsState appEvents, final boolean limitEventUsage, final FlushStatistics flushState) {
    String applicationId = accessTokenAppId.getApplicationId();
    FetchedAppSettings fetchedAppSettings = FetchedAppSettingsManager.queryAppSettings(applicationId, false);
    final GraphRequest postRequest = GraphRequest.newPostRequest(null, String.format("%s/activities", applicationId), null, null);
    Bundle requestParameters = postRequest.getParameters();
    if (requestParameters == null) {
        requestParameters = new Bundle();
    }
    requestParameters.putString("access_token", accessTokenAppId.getAccessTokenString());
    String pushNotificationsRegistrationId = AppEventsLogger.getPushNotificationsRegistrationId();
    if (pushNotificationsRegistrationId != null) {
        requestParameters.putString("device_token", pushNotificationsRegistrationId);
    }
    postRequest.setParameters(requestParameters);
    boolean supportsImplicitLogging = false;
    if (fetchedAppSettings != null) {
        supportsImplicitLogging = fetchedAppSettings.supportsImplicitLogging();
    }
    int numEvents = appEvents.populateRequest(postRequest, FacebookSdk.getApplicationContext(), supportsImplicitLogging, limitEventUsage);
    if (numEvents == 0) {
        return null;
    }
    flushState.numEvents += numEvents;
    postRequest.setCallback(new GraphRequest.Callback() {

        @Override
        public void onCompleted(GraphResponse response) {
            handleResponse(accessTokenAppId, postRequest, response, appEvents, flushState);
        }
    });
    return postRequest;
}
Also used : FetchedAppSettings(com.facebook.internal.FetchedAppSettings) GraphRequest(com.facebook.GraphRequest) GraphResponse(com.facebook.GraphResponse) Bundle(android.os.Bundle)

Example 3 with FetchedAppSettings

use of com.facebook.internal.FetchedAppSettings in project facebook-android-sdk by facebook.

the class AutomaticAnalyticsLogger method logActivityTimeSpentEvent.

public static void logActivityTimeSpentEvent(String activityName, long timeSpentInSeconds) {
    final Context context = FacebookSdk.getApplicationContext();
    final String appId = FacebookSdk.getApplicationId();
    Validate.notNull(context, "context");
    final FetchedAppSettings settings = FetchedAppSettingsManager.queryAppSettings(appId, false);
    if (settings != null && settings.getAutomaticLoggingEnabled() && timeSpentInSeconds > 0) {
        AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context);
        Bundle params = new Bundle(1);
        params.putCharSequence(Constants.AA_TIME_SPENT_SCREEN_PARAMETER_NAME, activityName);
        appEventsLogger.logEvent(Constants.AA_TIME_SPENT_EVENT_NAME, timeSpentInSeconds, params);
    }
}
Also used : Context(android.content.Context) FetchedAppSettings(com.facebook.internal.FetchedAppSettings) Bundle(android.os.Bundle) AppEventsLogger(com.facebook.appevents.AppEventsLogger)

Example 4 with FetchedAppSettings

use of com.facebook.internal.FetchedAppSettings in project facebook-android-sdk by facebook.

the class CustomTabLoginMethodHandler method isCustomTabsEnabled.

private boolean isCustomTabsEnabled() {
    final String appId = Utility.getMetadataApplicationId(loginClient.getActivity());
    final FetchedAppSettings settings = FetchedAppSettingsManager.getAppSettingsWithoutQuery(appId);
    return settings != null && settings.getCustomTabsEnabled();
}
Also used : FetchedAppSettings(com.facebook.internal.FetchedAppSettings)

Example 5 with FetchedAppSettings

use of com.facebook.internal.FetchedAppSettings in project facebook-android-sdk by facebook.

the class CustomTabLoginMethodHandlerTest method mockCustomTabsAllowed.

private void mockCustomTabsAllowed(final boolean allowed) {
    final FetchedAppSettings settings = mock(FetchedAppSettings.class);
    when(settings.getCustomTabsEnabled()).thenReturn(allowed);
    mockStatic(FetchedAppSettingsManager.class);
    when(FetchedAppSettingsManager.getAppSettingsWithoutQuery(anyString())).thenReturn(settings);
}
Also used : FetchedAppSettings(com.facebook.internal.FetchedAppSettings)

Aggregations

FetchedAppSettings (com.facebook.internal.FetchedAppSettings)6 Bundle (android.os.Bundle)2 Context (android.content.Context)1 GraphRequest (com.facebook.GraphRequest)1 GraphResponse (com.facebook.GraphResponse)1 AppEventsLogger (com.facebook.appevents.AppEventsLogger)1 FacebookRequestErrorClassification (com.facebook.internal.FacebookRequestErrorClassification)1 FetchedAppSettingsManager (com.facebook.internal.FetchedAppSettingsManager)1 JSONObject (org.json.JSONObject)1 Test (org.junit.Test)1