Commit c389c82d authored by Yusuke Iwaki's avatar Yusuke Iwaki

remove "push" related codes

parent 0ab3f4a1
......@@ -3,8 +3,6 @@ package chat.rocket.android;
import android.content.Context;
import android.content.SharedPreferences;
import java.util.UUID;
/**
* sharedpreference-based cache.
*/
......@@ -12,25 +10,10 @@ public class RocketChatCache {
public static final String KEY_SELECTED_SERVER_CONFIG_ID = "selectedServerConfigId";
public static final String KEY_SELECTED_ROOM_ID = "selectedRoomId";
private static final String PUSH_ID = "pushId";
/**
* get SharedPreference instance for RocketChat application cache.
*/
public static SharedPreferences get(Context context) {
return context.getSharedPreferences("cache", Context.MODE_PRIVATE);
}
public static String getPushId(Context context) {
SharedPreferences preferences = get(context);
String pushId = null;
if (!preferences.contains(PUSH_ID)) {
// generates one and save
pushId = UUID.randomUUID().toString();
SharedPreferences.Editor editor = preferences.edit();
editor.putString(PUSH_ID, pushId);
editor.apply();
}
return preferences.getString(PUSH_ID, pushId);
}
}
package chat.rocket.android.api;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Patterns;
import org.json.JSONArray;
import org.json.JSONException;
......@@ -19,7 +17,6 @@ import chat.rocket.android.model.ddp.PublicSetting;
import chat.rocket.android.model.ddp.RoomSubscription;
import chat.rocket.android.model.internal.MethodCall;
import chat.rocket.android.model.internal.Session;
import chat.rocket.android.model.params.PushUpdate;
import chat.rocket.android.realm_helper.RealmHelper;
import chat.rocket.android.realm_helper.RealmStore;
import chat.rocket.android_ddp.DDPClientCallback;
......@@ -27,7 +24,6 @@ import hugo.weaving.DebugLog;
/**
* Utility class for creating/handling MethodCall or RPC.
*
* TODO: separate method into several manager classes (SubscriptionManager, MessageManager, ...).
*/
public class MethodCallHelper {
......@@ -41,8 +37,9 @@ public class MethodCallHelper {
protected final RealmHelper realmHelper;
protected final DDPClientWrapper ddpClient;
@Deprecated
/**
* initialize with ServerConfigId.
* Deprecated. use MethodCall(Context, String) instead.
*/
public MethodCallHelper(String serverConfigId) {
this(null, serverConfigId);
......@@ -307,19 +304,6 @@ public class MethodCallHelper {
.onSuccessTask(task -> Task.forResult(null));
}
public Task<Void> pushUpdate(@NonNull String pushId, @NonNull String token,
@Nullable String userId) {
return call("raix:push-update", TIMEOUT_MS, () -> {
JSONObject param = new PushUpdate(pushId, token, userId).toJson();
return new JSONArray().put(param);
}).onSuccessTask(task -> Task.forResult(null));
}
public Task<Void> pushSetUser(String pushId) {
return call("raix:push-setuser", TIMEOUT_MS, () -> new JSONArray().put(pushId))
.onSuccessTask(task -> Task.forResult(null));
}
/**
* send message.
*/
......
......@@ -20,7 +20,6 @@ public class ServerConfig extends RealmObject {
public static final String STATE = "state";
public static final String SESSION = "session";
public static final String ERROR = "error";
public static final String SYNC_PUSH_TOKEN = "syncPushToken";
public static final int STATE_READY = 0;
public static final int STATE_CONNECTING = 1;
......@@ -32,7 +31,6 @@ public class ServerConfig extends RealmObject {
private int state;
private String session;
private String error;
private boolean syncPushToken;
/**
* Log the server connection is lost due to some exception.
......@@ -102,12 +100,4 @@ public class ServerConfig extends RealmObject {
public void setError(String error) {
this.error = error;
}
public boolean shouldSyncPushToken() {
return syncPushToken;
}
public void setSyncPushToken(boolean syncPushToken) {
this.syncPushToken = syncPushToken;
}
}
package chat.rocket.android.model.params;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
public class PushUpdate {
private String pushId;
private String gcmToken;
private String userId;
public PushUpdate(@NonNull String pushId, @NonNull String gcmToken, @Nullable String userId) {
this.pushId = pushId;
this.gcmToken = gcmToken;
this.userId = userId;
}
public JSONObject toJson() throws JSONException {
JSONObject param = new JSONObject();
param.put("id", pushId);
param.put("appName", "main");
param.put("userId", userId);
param.put("metadata", new JSONObject());
JSONObject tokenParam = new JSONObject();
tokenParam.put("gcm", gcmToken);
param.put("token", tokenParam);
return param;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment