app publish

This commit is contained in:
cimenmus
2018-08-27 00:53:08 +03:00
parent c44ac36660
commit 768a58666e
4 changed files with 44 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;
import com.onesignal.OneSignal;
import org.json.JSONException;
import org.json.JSONObject;
import butterknife.BindString;
@@ -58,6 +59,7 @@ public class ProfileFragment extends BaseFragment {
@BindString(R.string.bottom_nav_menu_item_profile) String fragmentTitle;
@BindString(R.string.alert_logout) String logoutAlertText;
@BindString(R.string.something_went_wrong) String genericErrorText;
public static final java.lang.String FRAGMENT_NAME = "profileFragment";
private int REQUEST_CODE_UPDATE_PROFILE = 2563;
@@ -173,13 +175,48 @@ public class ProfileFragment extends BaseFragment {
return;
}
DialogHelper.showLoadingDialog();
if(enableNotificationsSwitch.isChecked()) {
OneSignal.sendTag(
ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY,
ApiConstants.ONESIGNAL_NOTIFICATION_TAG_VALUE);
JSONObject tags = new JSONObject();
try {
tags.put(ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY, ApiConstants.ONESIGNAL_NOTIFICATION_TAG_VALUE);
OneSignal.sendTags(tags, new OneSignal.ChangeTagsUpdateHandler() {
@Override
public void onSuccess(JSONObject tags) {
DialogHelper.hideLoadingDialog();
}
@Override
public void onFailure(OneSignal.SendTagsError error) {
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
});
}
catch (JSONException e){
e.printStackTrace();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
}
else {
OneSignal.deleteTag(ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY);
OneSignal.deleteTag(
ApiConstants.ONESIGNAL_NOTIFICATION_TAG_KEY,
new OneSignal.ChangeTagsUpdateHandler() {
@Override
public void onSuccess(JSONObject tags) {
DialogHelper.hideLoadingDialog();
}
@Override
public void onFailure(OneSignal.SendTagsError error) {
DialogHelper.hideLoadingDialog();
DialogHelper.showAlertDialog(BaseActivity.currentActivity, genericErrorText);
}
}
);
}
}