2014-10-07 2 views
1

다른 콘텐츠를 공유하는 것에 대해 Android 앱을 프로그래밍하고 있습니다. 이제 소셜 네트워크를 개발하고 한 사용자가 새 친구를 추가 할 때 사용자가 추가 한 구문 분석 알림을 보냅니다.특정 사용자와 구문 분석 푸시 알림 보내기

저는 Parse SDK를 사용합니다. 지금은 어떻게하는지 모르겠습니다.

나는 이것을 시도 :

ParseInstallation installation = ParseInstallation.getCurrentInstallation(); 
installation.put("userId",id); 
try { 
    installation.save(); 

이 구문 분석 데이터의 설치 클래스의 사용자 ID 열을 만듭니다. (I는 구문 분석 데이터보고 및 사용자 ID 열은 사용자로부터 올바른 ID입니다)

다음으로 수행

//Create our Installation query 
    ParseQuery<ParseInstallation> pushQuery = ParseInstallation.getQuery(); 
    pushQuery.whereEqualTo("userId",ParseUser.getCurrentUser().getObjectId()); 

    // Send push notification to query 
    ParsePush push = new ParsePush(); 
    push.setQuery(pushQuery); // Set our Installation query 
    push.setMessage("Willie Hayes injured by own pop fly."); 
    push.sendInBackground(); 

나는 사용자 아이디 콜 럼 (즉, 당신을 추가 할 사용자의 사용자 ID를 포함 비교 쿼리를 만들)를 현재 ParseUser와 비교하지만 푸시는 보내지 않으며 아무도 수신하지 않습니다.

도와주세요.

감사합니다.

답변

1

내가 한 것은 사용자를 해당 채널에 등록한 것입니다. 스위프트에서 나는 이것을 좋아하지 만, 안드로이드에서는 매우 유사합니다. 즉, 사용자 "userId"는 "user_userId"채널에 가입하게됩니다.

let currentInstallation = PFInstallation.currentInstallation() 
currentInstallation.channels = ["user_" + PFUser.currentUser().objectId] 
currentInstallation.saveInBackground() 

푸시를 보내려면 "user_userId"채널로 보내십시오.

관련 문제