Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@raveeshbhalla
Created December 2, 2014 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raveeshbhalla/cc9f79367b06a8629414 to your computer and use it in GitHub Desktop.
Save raveeshbhalla/cc9f79367b06a8629414 to your computer and use it in GitHub Desktop.
NotiphiUtils
package co.haptik.utils;
import android.content.Context;
import android.content.SharedPreferences;
import com.notikum.notifypassive.utils.NotiphiEventReceiver;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by Raveesh on 02/12/14.
*/
public class NotiphiUtils {
private static SharedPreferences mPrefs;
private static SharedPreferences.Editor mEditor;
public static void init(Context context){
mPrefs = context.getSharedPreferences("Notiphi", Context.MODE_PRIVATE);
mEditor = mPrefs.edit();
}
public static void logUser(Context context, String username, String email){
boolean isFirstTimeInstall = mPrefs.getBoolean("isFirstTimeInstall", true);
if (isFirstTimeInstall) {
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("USERID", username);
jsonObject.put("EMAILID", email);
new NotiphiEventReceiver(jsonObject, context);
} catch (JSONException e) {
e.printStackTrace();
}
mEditor.putBoolean("isFirstTimeInstall", false);
mEditor.commit();
}
}
public static void logInstallSource(Context context, String source){
boolean isFirstSourceData = mPrefs.getBoolean("isFirstSourceData", true);
if (isFirstSourceData) {
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("SOURCEDATA", source); //provided by the app-store
new NotiphiEventReceiver(jsonObject, context);
} catch (JSONException e) {
e.printStackTrace();
}
}
mEditor.putBoolean("isFirstSourceData", false);
mEditor.commit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment