How can I group pushbullet notifications

别来无恙 提交于 2019-12-21 22:06:22

问题


I am sending push notifications to my Android phone. I want these notifications grouped so my notification list does not get flooded.

According to the documentation messages from the same 'source' get grouped but on my phone the messages always show up ungrouped.

I call the push API from a Google Apps script and have tried setting source_device_iden, source_user_iden and notification_tag when I call the push API. None of these seem to make any difference.

How can I get the pushmessages to be grouped on my phone?

Google Apps script code

function pushNoteToPhone(title, body) {
   var digest = "Basic "+Utilities.base64Encode(PUSH_BULLET_TOKEN+":");
   var options = {
    "method" : "post", 
    "payload" : {
      "device_iden" : MYPHONE_ID,
      "type" : "note",
      "title" : title,
      "body" : body,
      "source_device_iden" : <device id>,
      "notification_tag": "tag1",
    }, 
    "headers" : {
      "Authorization": digest
    }
  };

  var push_bullet_url = "https://api.pushbullet.com/v2/pushes";
  UrlFetchApp.fetch(push_bullet_url, options);
}

回答1:


The easiest way to do this (admittedly it should be easier) is to create an OAuth Client and then send using an access token for that oauth client. That way the pushes will all appear to come from that client instead of you. This is how IFTTT and Zapier work on Pushbullet.

Here's how to setup an oauth client: https://docs.pushbullet.com/#oauth

To get an access token you can use the "oauth test url" on the create client page, you will end up with an access token in the URL once you approve access. Use that access token instead of your normal one and the pushes will appear to come from the client instead of you.




回答2:


Don't know how you are trying to update the notification but without the code, my guess is that you are trying to pass a new Notification ID to each notification being sent to the device. However, please take a look here and look under, "Updating Notifications". As explained in the documentation, by passing the same ID to each notification it will either group these notifications on the device or create a new one in case the old one has been dismissed.



来源:https://stackoverflow.com/questions/29986166/how-can-i-group-pushbullet-notifications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!