Created
December 2, 2014 11:15
-
-
Save raveeshbhalla/cc9f79367b06a8629414 to your computer and use it in GitHub Desktop.
NotiphiUtils
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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