Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.