Skip to content

Differences in sync package API #632

@ttypic

Description

@ttypic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions