有什麼方法可以在默認Parse的推送通知處理程序上設置NotificationCompat.BigTextStyle()? 當我發送一個包含「alert」字段的push時,sdk會顯示默認樣式的通知以及修剪的文本。解析 - Android - 在默認推送通知上修剪文本
1
A
回答
1
你必須定製你的「數據」有效載荷。而不是通常的
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
}
});
你有你的有效載荷的手藝是這樣的,例如:
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
然後,在您的Android客戶端:
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(在你的清單文件,以及註冊課程),然後你可以提取的「推」數據從意向的額外JSON和工藝不過你希望你的通知顯示:
@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
編輯:
另一種方法:
1.)創建擴展ParsePushBroadcastReceiver(https://parse.com/docs/android/api/com/parse/ParsePushBroadcastReceiver.html)
2.)重寫方法中特別的GetNotification(上下文範圍內,意圖意圖)
3.)從那裏
相關問題
- 1. 在Android上解析推送通知
- 2. 解析推送通知
- 3. 解析.NET推送通知
- 4. 解析推送通知
- 5. Android靜默推送通知
- 6. Android解析sdk推送通知
- 7. 解析Android禁用推送通知
- 8. Android解析不會推送通知
- 9. 手柄解析推送通知(Android)
- 10. Android M權限解析推送通知
- 11. 解析推送通知iOS
- 12. 亞馬遜,解析,pushwoosh和默認GCM推送通知android之間的區別?
- 13. 不能發送解析推送通知
- 14. 解析推送通知不會出現在Android上的通知托盤上
- 15. 解析推送 - 推送通知系統爲Android應用程序
- 16. 推送通知未發送 - 解析SDK
- 17. 在解析推送通知框架
- 18. 解析正在推送通知? 8/15
- 19. 觸發/解析推送通知圖標
- 20. 在android中發送推送通知解析
- 21. 使用解析實現推送通知
- 22. 使用REST API解析推送通知
- 23. Android推送通知如何播放默認聲音
- 24. 解析推送通知在推送時包含用戶時區
- 25. 用自定義聲音解析推送通知播放默認聲音
- 26. 推送通知iOS與解析
- 27. 使用解析IOS推送通知
- 28. 解析推送通知與SWIFT 3
- 29. iPhone中的解析推送通知
- 30. 以gcm解析推送通知
撰寫BigStyle通知一個新的類我知道這一點,我正在使用該功能。但是,當您從Parse平臺發送簡單推送時,默認有效內容將包含默認字段「alert」。我的問題是指出,我需要告訴Parse可以使用BigContentView的默認處理程序。或者,如果這是不可能的,重寫默認處理程序,但我還沒有找到這樣做。 – 2014-12-05 01:27:14
我看到了,我更新了我的答案,嘗試了另一種方式(仍然使用默認有效載荷) – alpinescrambler 2014-12-05 16:28:06
我會盡力讓您知道,謝謝。 – 2014-12-08 19:48:04