Closed JJTech0130 closed 1 month ago
Note to self: the current receive API relies on the fact that the network is slower to respond than the scheduler is to schedule the receive task, as there is no backlog. Not necessarily an incorrect assumption, but should be noted.
The API is finished, it involved developing a new "Stream Filters" mechanism internally, but it leads to a nice clean test like this:
@pytest.mark.asyncio
async def test_scoped_token():
async with apns.create_apns_connection(
*await apns.activate(), courier="1-courier.sandbox.push.apple.com"
) as connection:
token = await connection.mint_scoped_token("dev.jjtech.pypush.tests")
test_message = f"test-message-{uuid.uuid4().hex}"
# Not part of pypush, uses Apple's public APNs API
await send_test_notification(token.hex(), test_message.encode())
await connection.expect_notification(
"dev.jjtech.pypush.tests",
token,
lambda c: c if c.payload == test_message.encode() else None,
)
New notifications
subcommand, for example:
pypush notifications dev.jjtech.pypush.tests --sandbox
Note that it currently does not provide any method of saving the certificate or tokens used.
You can test it out using your own CloudKit console if you have a Developer ID, or use the .pem file in the tests/assets/ directory and use it with any of the online APNs test websites.
Allows receiving notifications sent from the public APNs API
await connected
API