@Test public void testGetPushHashFromIntentEmptyPushHashIntent() throws Exception { Intent intent = new Intent(); Bundle bundle = new Bundle(); JSONObject json = new JSONObject(); json.put("push_hash_wrong_key", "test"); bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, json.toString()); intent.putExtras(bundle); String pushHash = ParseAnalytics.getPushHashFromIntent(intent); assertEquals("", pushHash); }
static String getPushHashFromIntent(Intent intent) { String pushData = null; if (intent != null && intent.getExtras() != null) { pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA); } if (pushData == null) { return null; } String pushHash = null; try { JSONObject payload = new JSONObject(pushData); pushHash = payload.optString("push_hash"); } catch (JSONException e) { PLog.e(TAG, "Failed to parse push data: " + e.getMessage()); } return pushHash; }
ParseAnalytics { static String getPushHashFromIntent(Intent intent) { String pushData = null; if (intent != null && intent.getExtras() != null) { pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA); } if (pushData == null) { return null; } String pushHash = null; try { JSONObject payload = new JSONObject(pushData); pushHash = payload.optString("push_hash"); } catch (JSONException e) { PLog.e(TAG, "Failed to parse push data: " + e.getMessage()); } return pushHash; } }
ParseAnalytics { static String getPushHashFromIntent(Intent intent) { String pushData = null; if (intent != null && intent.getExtras() != null) { pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA); } if (pushData == null) { return null; } String pushHash = null; try { JSONObject payload = new JSONObject(pushData); pushHash = payload.optString("push_hash"); } catch (JSONException e) { PLog.e(TAG, "Failed to parse push data: " + e.getMessage()); } return pushHash; }  }
ParseAnalytics { static String getPushHashFromIntent(Intent intent) { String pushData = null; if (intent != null && intent.getExtras() != null) { pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA); } if (pushData == null) { return null; } String pushHash = null; try { JSONObject payload = new JSONObject(pushData); pushHash = payload.optString("push_hash"); } catch (JSONException e) { PLog.e(TAG, "Failed to parse push data: " + e.getMessage()); } return pushHash; }  static Task<Void> trackAppOpenedInBackground(Intent intent); static void trackAppOpenedInBackground(Intent intent, SaveCallback callback); static void trackEventInBackground(String name, SaveCallback callback); static void trackEventInBackground(String name, Map<String, String> dimensions, SaveCallback callback); static Task<Void> trackEventInBackground(String name); static Task<Void> trackEventInBackground(final String name,
                                                    Map<String, String> dimensions); }
ParseAnalytics { static String getPushHashFromIntent(Intent intent) { String pushData = null; if (intent != null && intent.getExtras() != null) { pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA); } if (pushData == null) { return null; } String pushHash = null; try { JSONObject payload = new JSONObject(pushData); pushHash = payload.optString("push_hash"); } catch (JSONException e) { PLog.e(TAG, "Failed to parse push data: " + e.getMessage()); } return pushHash; }  static Task<Void> trackAppOpenedInBackground(Intent intent); static void trackAppOpenedInBackground(Intent intent, SaveCallback callback); static void trackEventInBackground(String name, SaveCallback callback); static void trackEventInBackground(String name, Map<String, String> dimensions, SaveCallback callback); static Task<Void> trackEventInBackground(String name); static Task<Void> trackEventInBackground(final String name,
                                                    Map<String, String> dimensions);  }