2013-12-16 3 views
1

Android parse sdk 푸시 알림이 에뮬레이터에서 작동하지만 USB 디버깅을 사용하여 휴대 전화에서 푸시 알림을 실행하면 내 parse.com 계정에서 푸시 알림이 표시됩니다. 전화가 푸시 알림을받지 못합니다.Android parse sdk 푸시 알림

public class Profile_InviteActivity extends Activity { 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_profile__invite); 

     Bundle extras = getIntent().getExtras();  
     ParseQuery<ParseObject> query = ParseQuery.getQuery("UserProfile"); 
     Log.d("id",""+extras.getInt("fid")); 

     query.whereEqualTo("fid", ""+extras.getInt("fid")); 
     query.findInBackground(new FindCallback<ParseObject>() { 
      public void done(final List<ParseObject> scoreList, ParseException e) { 
       if (e == null) { 

        TextView name = (TextView) findViewById(R.id.profile_name); 
        TextView location = (TextView) findViewById(R.id.profile_location); 


        name.setText(scoreList.get(0).getString("name")); 
        location.setText(scoreList.get(0).getString("location")); 



        ParseFile img1 = (ParseFile)scoreList.get(0).get("profileimage"); 

        img1.getDataInBackground(new GetDataCallback() { 

         public void done(byte[] data, 
           ParseException e) { 
          if (e == null) { 
           Log.d("test", 
             "We've got data in data."); 
           // Decode the Byte[] into 
           // Bitmap 
           ImageView image = (ImageView) findViewById(R.id.profimg); 


           image.setImageBitmap(BitmapFactory 
             .decodeByteArray(
               data, 0, 
               data.length)); 
          } else { 
           Log.d("test", 
             "There was a problem downloading the data."); 
          } 
         } 
        }); 

       } else { 
        Log.d("score", "Error: " + e.getMessage()); 
       } 
      } 
     }); 

    } 

    public void inviteToTrain(View v) 
    { 
     Log.d("inviting","now"); 

     Bundle extras = getIntent().getExtras(); 

     //ParseInstallation installation = ParseInstallation.getCurrentInstallation();  

     //installation.put("fids",true); 
     //installation.saveInBackground(); 

     ParseQuery pushQuery = ParseInstallation.getQuery(); 
     //pushQuery.whereEqualTo("fid", extras.getInt("fid")); 
     pushQuery.whereEqualTo("fids", true); 
     // Send push notification to query 
     ParsePush push = new ParsePush(); 
     push.setQuery(pushQuery); // Set our Installation query 
     push.setMessage("Someone would like to join you at your event "); 
     push.sendInBackground(); 
     Log.d("invited","now"); 
    } 

}

친절이 좀 도와.

감사 푸시 알림을 얻기 위하여

+0

코드가를 참조하십시오? – GrIsHu

+0

코드가 업데이트되었습니다 – rohit

답변

2

당신은 그것을 처리하기 위해 방송 수신기를 작성해야합니다.

샘플 코드 : 구문 분석 정보를 초기화 한 후, 그 다음 대시 보드를 구문 분석로 이동이

<receiver android:name="com.parse.ParseBroadcastReceiver" > 
    <intent-filter> 
     <action android:name="android.intent.action.BOOT_COMPLETED" /> 
     <action android:name="android.intent.action.USER_PRESENT" /> 
    </intent-filter> 
</receiver> 

를 추가, UR 매니페스트 파일에 다음이

PushService.setDefaultPushCallback(this, SampleClass.class); 

를 추가하고 수동으로 푸시를 확인하려면 inorder를 보내 푸시가 UR 전화로 전달되는지 여부. 이 같은 사용 JSON 형식,

{ "alert": "Notification", "title": "Push", "objectId": "objectId", 
"objectType": "type", "action": "Your Action Name" } 

상세 정보,

How to trigger an event using Parse for Android via push notification?

+0

고마워요,하지만 이미이 작업을 완료했습니다. 이처럼 새 개체를 만들 때만 휴대 전화에 푸시 알림을 보내고 있습니다. 매번 등록 된 것들과 작동하지 않습니다. ParseInstallation installation = ParseInstallation.getCurrentInstallation(); installation.put ("fids", true); installation.saveInBackground(); – rohit

+0

나는 무엇을 말하는지 모르겠다. 여기에 몇 가지 샘플 코드를 넣어 라. –