instapush/libs/gcm.py
def send_plain(self):
        """
        Sends a text/plain GCM message
        """

        values = {"registration_id": self._registration_id}

        for key, val in self._data.items():
            values["data.%s" % (key)] = val.encode(self.encoding)

        for key, val in self._kwargs.items():
            if val and isinstance(val, bool):
                val = 1
                values[key] = val

        data = urlencode(sorted(values.items())).encode(self.encoding)
        result = self._send(data, "application/x-www-form-urlencoded;charset=UTF-8")

        if result.startswith("Error="):
            if result in ("Error=NotRegistered", "Error=InvalidRegistration"):
                ## TODO: deactivate the unregistered device
                return result

            raise GCMPushError(result)

        return result
def send_plain(self):
        """
        Sends a text/plain GCM message
        """

        values = {"registration_id": self._registration_id}

        for key, val in self._data.items():
            values["data.%s" % (key)] = val.encode(self.encoding)

        for key, val in self._kwargs.items():
            if val and isinstance(val, bool):
                val = 1
                values[key] = val

        data = urlencode(sorted(values.items())).encode(self.encoding)
        result = self._send(data, "application/x-www-form-urlencoded;charset=UTF-8")

        if result.startswith("Error="):
            if result in ("Error=NotRegistered", "Error=InvalidRegistration"):
                ## TODO: deactivate the unregistered device
                return result

            raise GCMPushError(result)

        return result
def send_plain ( self ) : values = { "registration_id" : self . _registration_id } for key , val in self . _data . items ( ) : values [ "data.%s" % ( key ) ] = val . encode ( self . encoding ) for key , val in self . _kwargs . items ( ) : if val and isinstance ( val , bool ) : val = 1 values [ key ] = val data = urlencode ( sorted ( values . items ( ) ) ) . encode ( self . encoding ) result = self . _send ( data , "application/x-www-form-urlencoded;charset=UTF-8" ) if result . startswith ( "Error=" ) : if result in ( "Error=NotRegistered" , "Error=InvalidRegistration" ) : ## TODO: deactivate the unregistered device return result raise GCMPushError ( result ) return result
Sends a text/plain GCM message
Sends a text / plain GCM message