How can I group pushbullet notifications

2020-07-23 07:05发布

问题:

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.