private void uploadUserDetails(String registrationId, String instanceId) { SharedPreferences sharedPreferences = StudentAssistApplication.getAppContext() .getSharedPreferences(SAConstants.sharedPreferenceName, 0); // setting GCM id to user and storing it into shared preferences SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(SAConstants.GCM_ID, registrationId); editor.putString(SAConstants.INSTANCE_ID, instanceId); editor.commit(); String fbToken = ""; if (AccessToken.getCurrentAccessToken() != null && !AccessToken.getCurrentAccessToken().isExpired()) { fbToken = AccessToken.getCurrentAccessToken().getToken(); } else { Toast.makeText(StudentAssistApplication.getAppContext(), "not registered", Toast.LENGTH_LONG) .show(); } UrlInterface urlGen = new UrlGenerator(); try { String url = urlGen.createUser(fbToken, instanceId); new NotificationBO( new NotificationBI() { @Override public void onResponse(String response) { L.m("successfully created user"); } }, url); } catch (Exception e) { ErrorReporting.logReport(e); } }
private String getAccessToken() { FacebookSdk.sdkInitialize(StudentAssistApplication.getAppContext()); if (AccessToken.getCurrentAccessToken() != null && !AccessToken.getCurrentAccessToken().isExpired()) { String fbToken = AccessToken.getCurrentAccessToken().getToken(); return fbToken; } return ""; }