Skip to content

Instantly share code, notes, and snippets.

@YoungjaeKim
Created September 27, 2013 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoungjaeKim/6725587 to your computer and use it in GitHub Desktop.
Save YoungjaeKim/6725587 to your computer and use it in GitHub Desktop.
푸쉬 서비스 처리.
// JSON 메시지 해석.
try {
if (jsonObject != null) {
resultIntent.putExtra("PushType", jsonObject.getString("type"));
if (jsonObject.getString("type").equalsIgnoreCase("Reply")) {
targetId = jsonObject.getString("questionId");
ticker = "새 답변이 달렸어요";
title = getString(R.string.pushReplyArrivedPrefix);
message = jsonObject.getString("text");
resultIntent.putExtra("questionId", targetId);
}
if (jsonObject.getString("type").equalsIgnoreCase("REPLY_COMMENT")) {
String author = jsonObject.has("username") ? jsonObject.getString("username") : jsonObject.getString("opponent");
ticker = author + "님이 댓글을 달았습니다.";
title = author + "님의 댓글";
message = jsonObject.getString("text");
// TODO: "replyId":"ReplyId(number=-5546285000849732677)" 처리 필요. 해당 질문이 하이라이트 되도록.
targetId = jsonObject.getString("questionId");
resultIntent.putExtra("questionId", targetId);
}
if (jsonObject.getString("type").equalsIgnoreCase("Question")) {
targetId = jsonObject.getString("questionId");
ticker = "친구의 질문이 올라왔어요";
title = getString(R.string.pushQuestionPrefix);
message = jsonObject.getString("text");
resultIntent.putExtra("questionId", targetId);
}
if (jsonObject.getString("type").equalsIgnoreCase("Talk")) {
targetId = jsonObject.has("username") ? jsonObject.getString("username") : jsonObject.getString("opponent");
ticker = targetId + "님이 토크를 남겼습니다.";
title = targetId + "님의 토크";
message = jsonObject.getString("text");
// 내 프로필을 보일 것이므로 Intent 부가정보는 필요 없음.
}
if (jsonObject.getString("type").equalsIgnoreCase("Connect")) {
targetId = jsonObject.has("username") ? jsonObject.getString("username") : jsonObject.getString("opponent");
ticker = "바풀러 " + targetId + "님과 연결되었습니다.";
title = targetId + "님과 연결";
message = "새 바풀러를 만나보세요!";
resultIntent.putExtra("opponent", targetId);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment