Ejemplo n.º 1
0
  def xmlrpc_feedback(self, app_id, provider):
    """ Queries the Apple APNS feedback server for inactive app tokens. Returns
    a list of tuples as (datetime_went_dark, token_str).

      Arguments:
          app_id   the app_id to query
      Returns:
          Feedback tuples like (datetime_expired, token_str)
    """

    return get_service(app_id, provider).feedback().addCallback(
      lambda r: decode_feedback(r))
Ejemplo n.º 2
0
  def xmlrpc_notify(self, app_id, provider, token_or_token_list, aps_dict_or_list):
    """ Sends push notifications to the PNS server. Multiple 
    notifications can be sent by sending pairing the token/notification
    arguments in lists [token1, token2], [notification1, notification2].

      Arguments:
          app_id                provisioned app_id to send to
          token_or_token_list   token to send the notification or a list of tokens
          aps_dict_or_list      notification dicts or a list of notifications
      Returns:
          None
    """
    d = get_service(app_id, provider).notify(token_or_token_list, aps_dict_or_list)
    if d:
      def _finish_err(r):
        # so far, the only error that could really become of this
        # request is a timeout, since PNS simply terminates connectons
        # that are made unsuccessfully, which twisted will try endlessly
        # to reconnect to, we timeout and notifify the client
        raise xmlrpc.Fault(500, 'Connection to the PNS server could not be made.')
      return d.addCallbacks(lambda r: None, _finish_err)