Skip to content

APNS_TOPIC not documented adequately #377

@matthewh

Description

@matthewh

This issue only impacts the unreleased master branch.

If APNS_TOPIC is not present in settings, sending an APNS notification fails. The setting is mentioned in the example configuration but is not defined under the APNS settings section. It would be appropriate to default APNS_TOPIC to "" in settings given the following developer documentation.

The topic of the remote notification, which is typically the bundle ID for your app. The certificate you create in your developer account must include the capability for this topic.
If your certificate includes multiple topics, you must specify a value for this header.
If you omit this request header and your APNs certificate does not specify multiple topics, the APNs server uses the certificate’s Subject as the default topic.
If you are using a provider token instead of a certificate, you must specify a value for this request header. The topic you provide should be provisioned for the your team named in your developer account.

push_notifications/api/registry.py:219: in save
    apns_devices.send_message(**apns_data)
push_notifications/models.py:153: in send_message
    certfile=certfile, **kwargs
push_notifications/apns.py:132: in apns_send_bulk_message
    registration_ids, alert, batch=True, application_id=application_id, certfile=certfile, **kwargs
push_notifications/apns.py:87: in _apns_send
    data, SETTINGS.get("APNS_TOPIC"), **notification_kwargs)
../envs/django-push-notifications-server/lib/python3.5/site-packages/apns2/client.py:101: in send_notification_batch
    priority, expiration)
../envs/django-push-notifications-server/lib/python3.5/site-packages/apns2/client.py:57: in send_notification_async
    stream_id = self.__connection.request('POST', url, json_payload, headers)
../envs/django-push-notifications-server/lib/python3.5/site-packages/hyper/http20/connection.py:275: in request
    self.putheader(name, value, stream_id, replace=is_default)
../envs/django-push-notifications-server/lib/python3.5/site-packages/hyper/http20/connection.py:522: in putheader
    stream.add_header(header, argument, replace)
../envs/django-push-notifications-server/lib/python3.5/site-packages/hyper/http20/stream.py:88: in add_header
    self.headers[name] = value
../envs/django-push-notifications-server/lib/python3.5/site-packages/hyper/common/headers.py:94: in __setitem__
    self._items.append(to_bytestring_tuple(key, value))
../envs/django-push-notifications-server/lib/python3.5/site-packages/hyper/common/util.py:30: in to_bytestring_tuple
    return tuple(imap(to_bytestring, x))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

element = None

    def to_bytestring(element):
        """
        Converts a single string to a bytestring, encoding via UTF-8 if needed.
        """
        if isinstance(element, unicode):
            return element.encode('utf-8')
        elif isinstance(element, bytes):
            return element
        else:
>           raise ValueError("Non string type.")
E           ValueError: Non string type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions