com.facebook.internal.AttributionIdentifiers Java Examples
The following examples show how to use
com.facebook.internal.AttributionIdentifiers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppEventsLogger.java From Abelana-Android with Apache License 2.0 | 6 votes |
private static SessionEventsState getSessionEventsState(Context context, AccessTokenAppIdPair accessTokenAppId) { // Do this work outside of the lock to prevent deadlocks in implementation of // AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on the main thread, // which may also grab this staticLock. SessionEventsState state = stateMap.get(accessTokenAppId); AttributionIdentifiers attributionIdentifiers = null; if (state == null) { // Retrieve attributionId, but we will only send it if attribution is supported for the app. attributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(context); } synchronized (staticLock) { // Check state again while we're locked. state = stateMap.get(accessTokenAppId); if (state == null) { state = new SessionEventsState(attributionIdentifiers, context.getPackageName(), hashedDeviceAndAppId); stateMap.put(accessTokenAppId, state); } return state; } }
Example #2
Source File: AppEventsLogger.java From facebook-api-android-maven with Apache License 2.0 | 6 votes |
private static SessionEventsState getSessionEventsState(Context context, AccessTokenAppIdPair accessTokenAppId) { // Do this work outside of the lock to prevent deadlocks in implementation of // AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on the main thread, // which may also grab this staticLock. SessionEventsState state = stateMap.get(accessTokenAppId); AttributionIdentifiers attributionIdentifiers = null; if (state == null) { // Retrieve attributionId, but we will only send it if attribution is supported for the app. attributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(context); } synchronized (staticLock) { // Check state again while we're locked. state = stateMap.get(accessTokenAppId); if (state == null) { state = new SessionEventsState(attributionIdentifiers, context.getPackageName(), hashedDeviceAndAppId); stateMap.put(accessTokenAppId, state); } return state; } }
Example #3
Source File: AppEventsLogger.java From kognitivo with Apache License 2.0 | 5 votes |
private static SessionEventsState getSessionEventsState( Context context, AccessTokenAppIdPair accessTokenAppId) { // Do this work outside of the lock to prevent deadlocks in implementation of // AdvertisingIdClient.getAdvertisingIdInfo, because that implementation blocks waiting on // the main thread, which may also grab this staticLock. SessionEventsState state = stateMap.get(accessTokenAppId); AttributionIdentifiers attributionIdentifiers = null; if (state == null) { // Retrieve attributionId, but we will only send it if attribution is supported for the // app. attributionIdentifiers = AttributionIdentifiers.getAttributionIdentifiers(context); } synchronized (staticLock) { // Check state again while we're locked. state = stateMap.get(accessTokenAppId); if (state == null) { state = new SessionEventsState( attributionIdentifiers, context.getPackageName(), getAnonymousAppDeviceGUID(context)); stateMap.put(accessTokenAppId, state); } return state; } }
Example #4
Source File: AppEventsLogger.java From kognitivo with Apache License 2.0 | 5 votes |
public SessionEventsState( AttributionIdentifiers identifiers, String packageName, String anonymousGUID) { this.attributionIdentifiers = identifiers; this.packageName = packageName; this.anonymousAppDeviceGUID = anonymousGUID; }
Example #5
Source File: Settings.java From android-skeleton-project with MIT License | 4 votes |
static Response publishInstallAndWaitForResponse( final Context context, final String applicationId, final boolean isAutoPublish) { try { if (context == null || applicationId == null) { throw new IllegalArgumentException("Both context and applicationId must be non-null"); } AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context); SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE); String pingKey = applicationId+"ping"; String jsonKey = applicationId+"json"; long lastPing = preferences.getLong(pingKey, 0); String lastResponseJSON = preferences.getString(jsonKey, null); // prevent auto publish from occurring if we have an explicit call. if (!isAutoPublish) { setShouldAutoPublishInstall(false); } GraphObject publishParams = GraphObject.Factory.create(); publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT); Utility.setAppEventAttributionParameters(publishParams, identifiers, Utility.getHashedDeviceAndAppID(context, applicationId), getLimitEventAndDataUsage(context)); publishParams.setProperty(AUTO_PUBLISH, isAutoPublish); publishParams.setProperty("application_package_name", context.getPackageName()); String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId); Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null); if (lastPing != 0) { GraphObject graphObject = null; try { if (lastResponseJSON != null) { graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON)); } } catch (JSONException je) { // return the default graph object if there is any problem reading the data. } if (graphObject == null) { return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0); } else { return new Response(null, null, null, graphObject, true); } } else if (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null) { throw new FacebookException("No attribution id available to send to server."); } else { if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) { throw new FacebookException("Install attribution has been disabled on the server."); } Response publishResponse = publishRequest.executeAndWait(); // denote success since no error threw from the post. SharedPreferences.Editor editor = preferences.edit(); lastPing = System.currentTimeMillis(); editor.putLong(pingKey, lastPing); // if we got an object response back, cache the string of the JSON. if (publishResponse.getGraphObject() != null && publishResponse.getGraphObject().getInnerJSONObject() != null) { editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString()); } editor.commit(); return publishResponse; } } catch (Exception e) { // if there was an error, fall through to the failure case. Utility.logd("Facebook-publish", e); return new Response(null, null, new FacebookRequestError(null, e)); } }
Example #6
Source File: Settings.java From FacebookImageShareIntent with MIT License | 4 votes |
static Response publishInstallAndWaitForResponse( final Context context, final String applicationId, final boolean isAutoPublish) { try { if (context == null || applicationId == null) { throw new IllegalArgumentException("Both context and applicationId must be non-null"); } AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context); SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE); String pingKey = applicationId+"ping"; String jsonKey = applicationId+"json"; long lastPing = preferences.getLong(pingKey, 0); String lastResponseJSON = preferences.getString(jsonKey, null); // prevent auto publish from occurring if we have an explicit call. if (!isAutoPublish) { setShouldAutoPublishInstall(false); } GraphObject publishParams = GraphObject.Factory.create(); publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT); Utility.setAppEventAttributionParameters(publishParams, identifiers, Utility.getHashedDeviceAndAppID(context, applicationId), getLimitEventAndDataUsage(context)); publishParams.setProperty(AUTO_PUBLISH, isAutoPublish); publishParams.setProperty("application_package_name", context.getPackageName()); String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId); Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null); if (lastPing != 0) { GraphObject graphObject = null; try { if (lastResponseJSON != null) { graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON)); } } catch (JSONException je) { // return the default graph object if there is any problem reading the data. } if (graphObject == null) { return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0); } else { return new Response(null, null, null, graphObject, true); } } else if (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null) { throw new FacebookException("No attribution id available to send to server."); } else { if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) { throw new FacebookException("Install attribution has been disabled on the server."); } Response publishResponse = publishRequest.executeAndWait(); // denote success since no error threw from the post. SharedPreferences.Editor editor = preferences.edit(); lastPing = System.currentTimeMillis(); editor.putLong(pingKey, lastPing); // if we got an object response back, cache the string of the JSON. if (publishResponse.getGraphObject() != null && publishResponse.getGraphObject().getInnerJSONObject() != null) { editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString()); } editor.commit(); return publishResponse; } } catch (Exception e) { // if there was an error, fall through to the failure case. Utility.logd("Facebook-publish", e); return new Response(null, null, new FacebookRequestError(null, e)); } }
Example #7
Source File: AppEventsLogger.java From Abelana-Android with Apache License 2.0 | 4 votes |
public SessionEventsState(AttributionIdentifiers identifiers, String packageName, String hashedDeviceAndAppId) { this.attributionIdentifiers = identifiers; this.packageName = packageName; this.hashedDeviceAndAppId = hashedDeviceAndAppId; }
Example #8
Source File: Settings.java From Abelana-Android with Apache License 2.0 | 4 votes |
static Response publishInstallAndWaitForResponse( final Context context, final String applicationId, final boolean isAutoPublish) { try { if (context == null || applicationId == null) { throw new IllegalArgumentException("Both context and applicationId must be non-null"); } AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context); SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE); String pingKey = applicationId+"ping"; String jsonKey = applicationId+"json"; long lastPing = preferences.getLong(pingKey, 0); String lastResponseJSON = preferences.getString(jsonKey, null); // prevent auto publish from occurring if we have an explicit call. if (!isAutoPublish) { setShouldAutoPublishInstall(false); } GraphObject publishParams = GraphObject.Factory.create(); publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT); Utility.setAppEventAttributionParameters(publishParams, identifiers, Utility.getHashedDeviceAndAppID(context, applicationId), getLimitEventAndDataUsage(context)); publishParams.setProperty(AUTO_PUBLISH, isAutoPublish); publishParams.setProperty("application_package_name", context.getPackageName()); String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId); Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null); if (lastPing != 0) { GraphObject graphObject = null; try { if (lastResponseJSON != null) { graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON)); } } catch (JSONException je) { // return the default graph object if there is any problem reading the data. } if (graphObject == null) { return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0); } else { return new Response(null, null, null, graphObject, true); } } else if (identifiers == null || (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null)) { throw new FacebookException("No attribution id available to send to server."); } else { if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) { throw new FacebookException("Install attribution has been disabled on the server."); } Response publishResponse = publishRequest.executeAndWait(); // denote success since no error threw from the post. SharedPreferences.Editor editor = preferences.edit(); lastPing = System.currentTimeMillis(); editor.putLong(pingKey, lastPing); // if we got an object response back, cache the string of the JSON. if (publishResponse.getGraphObject() != null && publishResponse.getGraphObject().getInnerJSONObject() != null) { editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString()); } editor.commit(); return publishResponse; } } catch (Exception e) { // if there was an error, fall through to the failure case. Utility.logd("Facebook-publish", e); return new Response(null, null, new FacebookRequestError(null, e)); } }
Example #9
Source File: AppEventsLogger.java From facebook-api-android-maven with Apache License 2.0 | 4 votes |
public SessionEventsState(AttributionIdentifiers identifiers, String packageName, String hashedDeviceAndAppId) { this.attributionIdentifiers = identifiers; this.packageName = packageName; this.hashedDeviceAndAppId = hashedDeviceAndAppId; }
Example #10
Source File: Settings.java From facebook-api-android-maven with Apache License 2.0 | 4 votes |
static Response publishInstallAndWaitForResponse( final Context context, final String applicationId, final boolean isAutoPublish) { try { if (context == null || applicationId == null) { throw new IllegalArgumentException("Both context and applicationId must be non-null"); } AttributionIdentifiers identifiers = AttributionIdentifiers.getAttributionIdentifiers(context); SharedPreferences preferences = context.getSharedPreferences(ATTRIBUTION_PREFERENCES, Context.MODE_PRIVATE); String pingKey = applicationId+"ping"; String jsonKey = applicationId+"json"; long lastPing = preferences.getLong(pingKey, 0); String lastResponseJSON = preferences.getString(jsonKey, null); // prevent auto publish from occurring if we have an explicit call. if (!isAutoPublish) { setShouldAutoPublishInstall(false); } GraphObject publishParams = GraphObject.Factory.create(); publishParams.setProperty(ANALYTICS_EVENT, MOBILE_INSTALL_EVENT); Utility.setAppEventAttributionParameters(publishParams, identifiers, Utility.getHashedDeviceAndAppID(context, applicationId), getLimitEventAndDataUsage(context)); publishParams.setProperty(AUTO_PUBLISH, isAutoPublish); publishParams.setProperty("application_package_name", context.getPackageName()); String publishUrl = String.format(PUBLISH_ACTIVITY_PATH, applicationId); Request publishRequest = Request.newPostRequest(null, publishUrl, publishParams, null); if (lastPing != 0) { GraphObject graphObject = null; try { if (lastResponseJSON != null) { graphObject = GraphObject.Factory.create(new JSONObject(lastResponseJSON)); } } catch (JSONException je) { // return the default graph object if there is any problem reading the data. } if (graphObject == null) { return Response.createResponsesFromString("true", null, new RequestBatch(publishRequest), true).get(0); } else { return new Response(null, null, null, graphObject, true); } } else if (identifiers == null || (identifiers.getAndroidAdvertiserId() == null && identifiers.getAttributionId() == null)) { throw new FacebookException("No attribution id available to send to server."); } else { if (!Utility.queryAppSettings(applicationId, false).supportsAttribution()) { throw new FacebookException("Install attribution has been disabled on the server."); } Response publishResponse = publishRequest.executeAndWait(); // denote success since no error threw from the post. SharedPreferences.Editor editor = preferences.edit(); lastPing = System.currentTimeMillis(); editor.putLong(pingKey, lastPing); // if we got an object response back, cache the string of the JSON. if (publishResponse.getGraphObject() != null && publishResponse.getGraphObject().getInnerJSONObject() != null) { editor.putString(jsonKey, publishResponse.getGraphObject().getInnerJSONObject().toString()); } editor.commit(); return publishResponse; } } catch (Exception e) { // if there was an error, fall through to the failure case. Utility.logd("Facebook-publish", e); return new Response(null, null, new FacebookRequestError(null, e)); } }