ably-python icon indicating copy to clipboard operation
ably-python copied to clipboard

Differences in `sync` package API

Open ttypic opened this issue 2 months ago • 0 comments

In sync version publish only works with array of messages and in regular (async) package publish works with single message object:

sync:

from ably.sync import AblyRestSync
from ably.types.message import Message

def main():
  ably = AblyRestSync('<your_api_key>')
  channel = ably.channels.get('push:12345')
  extras = {
    'push': {
      'notification': {"title": "Testing"},
    }
  }
  message = Message(name='event', data='message', extras=extras)
  channel.publish([message])

if __name__ == "__main__": main()

async:

from ably import AblyRest
from ably.types.message import Message

def main():
  ably = AblyRest('<your_api_key>')
  channel = ably.channels.get('push:12345')
  extras = {
    'push': {
      'notification': {"title": "Testing"},
    }
  }
  message = Message(name='event', data='message', extras=extras)
  channel.publish(message)

if __name__ == "__main__": main()

┆Issue is synchronized with this Jira Task by Unito

ttypic avatar Oct 22 '25 14:10 ttypic