2

I'm writing a swift app for the Pushbullet API for SMS notifications and replies on MacOS.

To get new SMS messages, I'm monitoring the WebSocket wss://stream.pushbullet.com/websocket/ for sms_changed events, which works nicely. I get the contact name, message body, and contact picture from that.

The issue I have is, when it comes to replying, you supply amongst other data, a "conversation_iden" to https://api.pushbullet.com/v2/ephemerals, which is documented as being the phone number. However, I do not receive the contact's phone number in the event stream, only the thread ID.

How can I get a contact's number from an sms_changed event instead of the thread_id?

Thanks!

user2521989
  • 93
  • 1
  • 6

1 Answers1

4

This isn't shown in the API but it works for me. Assuming your DEVICE_IDEN is ABC123 If you call https://api.pushbullet.com/v2/permanents/ABC123_threads, It'll give you the threads information for that device. Ex:

[
     {
      id: '184',
      recipients: [
        { name: 'Joe', address: '+19171234567', number: '9171234567' }
      ],
      latest: {
          id: '15531',
          type: 'sms',
          timestamp: 1472534904,
          direction: 'incoming',
          body: 'Hey dude'
      }
     }
]

Then if you call https://api.pushbullet.com/v2/permanents/ABC123_thread_184. It'll give you the latest information for that conversation. So you can call this when you get the sms_changed event.