2014-12-03 3 views

답변

1

"데이터"페이로드를 사용자 정의해야합니다.

var myData = { 

    action:"com.yourcompany.blahblah.UPDATE_SOMETHING", // take note of this!!! 
    message:"You are awesome", 
    somethingelse:3 
}; 

// Note: some "data" field names are reserved 

    Parse.Push.send({ 
    channels: [ "Mets" ], 
    data: myData 
}, { 
    success: function() { 
    // Push was successful 
    }, 
    error: function(error) { 
    // Handle error 
    } 
}); 

당신은 문서에서 볼 수 있습니다 : 다음 https://parse.com/docs/push_guide#options-data/JavaScript

을 그리고, 대신에 일반적인

Parse.Push.send({ 
    channels: [ "Giants", "Mets" ], 
    data: { 
    alert: "The Giants won against the Mets 2-3." 
    } 
}, { 
    success: function() { 
    // Push was successful 
    }, 
    error: function(error) { 
    // Handle error 
    } 
}); 

당신은 예를 들어 이런 식으로 뭔가에 페이로드를 공예해야합니다의 귀하의 안드로이드 클라이언트 :

1.) 매니 페스트 파일에서 다음 태그를 제거하십시오.

<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> 
<receiver android:name="com.parse.ParsePushBroadcastReceiver" 
    android:exported="false"> 
    <intent-filter> 
    <action android:name="com.parse.push.intent.RECEIVE" /> 
    <action android:name="com.parse.push.intent.DELETE" /> 
    <action android:name="com.parse.push.intent.OPEN" /> 
    </intent-filter> 
</receiver> 

2.) 자신의 BroadcastReceiver (WakefulBroadcastReceiver 유형 제안)를 작성한 다음 IntentService를 실행하여 알림을 표시합니다. 이 방송 수신기는 사용자 정의 데이터 페이로드에 이전에 지정한 작업을 청취 :

<receiver 
    android:name="com.yourcompany.blahblah.MyCustomReceiver" 
    android:enabled="true" 
    android:exported="false" > 
    <intent-filter> 
     <action android:name="com.yourcompany.blahblah.UPDATE_SOMETHING" /> 
    </intent-filter> 
</receiver> 

3) 당신의 IntentService에서 (뿐만 아니라 매니페스트 파일에 등록 과정), 당신은 다음 추출 수의 데이터를 "밀어"

@Override 
protected void onHandleIntent(Intent intent) { 

     final Bundle extras = intent.getExtras(); 
     final JSONObject json = new JSONObject(extras.getString("com.parse.Data")); 
     // keys matching your myData payload object names/keys 
     final String message = json.getString("message"); 
     final int somethingelse = json.getInt("somethingelse"); 

     // YOUR code to compose the Notification however you want it to appear follows here 

편집 :

또 다른 방법 :

을 텐트의 엑스트라에서 JSON, 공예품 그러나 당신은 당신의 통지를 표시 할

1. 는) ParsePushBroadcastReceiver

2 (https://parse.com/docs/android/api/com/parse/ParsePushBroadcastReceiver.html)

)) 방법, 특히 getNotification (컨텍스트 컨텍스트, 의도 의도)

3. 재정

+0

거기에서 BigStyle 알림을 구성을 확장하는 새 클래스를 만듭니다 나는 그것을 알고 있으며 나는 그 특징을 사용하고있다. 그러나 Parse의 플랫폼에서 간단한 푸시를 보내면 기본 페이로드에 기본 필드 인 "경고"가 포함됩니다. 내 질문에 가리키는, BigelentView 사용할 수있는 기본 처리기를 구문 분석 할 teel. 또는 가능하지 않은 경우 기본 처리기를 재정의하지만 그 작업을 수행 할 수있는 방법을 찾지 못했습니다. –

+0

나는 (기본 페이로드를 사용하는) 다른 방법을 시도하기 위해 나의 대답을 업데이트했다. – alpinescrambler

+0

나는 당신에게 감사 할 것입니다. –

관련 문제