def send_iphone_notify(): try: queue = Queue('notify') #configure({'HOST': 'http://localhost:7077/'}) #provision('justoa', open(os.path.join(os.path.dirname(__file__), 'iphone/cert.pem')).read(), 'production') while 1: data = queue.rpop() if data: wrapper = APNSNotificationWrapper(os.path.join(os.path.dirname(__file__), 'iphone/cert.pem'), True) message = APNSNotification() data = json.loads(data) deviceToken = binascii.unhexlify(data['iphone_token']) message.token(deviceToken) alert = APNSAlert() body = str(data['message']) alert.body(body) message.alert(alert) message.badge(1) message.sound() wrapper.append(message) wrapper.notify() #notify('justoa', data['iphone_token'], {'aps':{'alert': data['message'], 'sound': 'default'}}) except: pass