Skip to content

Commit

Permalink
Make apns work
Browse files Browse the repository at this point in the history
  • Loading branch information
Amyth Singh committed Feb 26, 2016
1 parent 3ef74a5 commit 81f5c8d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 82 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -63,3 +63,9 @@ target/


## Swp files ## Swp files
*.swp *.swp

## templ
temp/

## DB
db.*
6 changes: 2 additions & 4 deletions apps/home/forms.py
Expand Up @@ -18,7 +18,7 @@ def clean_pem_certificate(self):


f = self.cleaned_data.get('pem_certificate') f = self.cleaned_data.get('pem_certificate')
content = f.readlines() content = f.readlines()
tfile = open("temp/%s" % f.name, 'w') tfile = open("/tmp/%s" % f.name, 'w')
tfile.writelines(content) tfile.writelines(content)
filename = os.path.abspath(tfile.name) filename = os.path.abspath(tfile.name)
tfile.close() tfile.close()
Expand All @@ -33,9 +33,7 @@ def send_message(self, *args, **kwargs):
json_data = data.get('apns_data') json_data = data.get('apns_data')
message_obj = json.loads(json_data) if json_data else {"message": message} message_obj = json.loads(json_data) if json_data else {"message": message}


print pem_cert return apns.apns_send_bulk_message(ids, message_obj, certfile=os.path.abspath(pem_cert))

return apns.apns_send_bulk_message(ids, message_obj, certfile=pem_cert)




class GCMForm(forms.Form): class GCMForm(forms.Form):
Expand Down
11 changes: 3 additions & 8 deletions apps/home/views.py
Expand Up @@ -21,15 +21,10 @@ class APNSTester(FormView):


def form_valid(self, form, *args, **kwargs): def form_valid(self, form, *args, **kwargs):


result = form.send_message()
try: try:
result = form.send_message() x = form.send_message()
print result print x
if result.get('failure'): messages.success(self.request, 'Message(s) sent.')
error = result.get('results')[0]['error']
messages.error(self.request, error)
elif result.get('success'):
messages.success(self.request, 'Message(s) sent.')
except Exception as err: except Exception as err:
messages.error(self.request, str(err)) messages.error(self.request, str(err))


Expand Down
2 changes: 1 addition & 1 deletion config/settings.py
Expand Up @@ -25,7 +25,7 @@
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True


ALLOWED_HOSTS = [] ALLOWED_HOSTS = ["*"]




# Application definition # Application definition
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,7 +1,7 @@
appnope==0.1.0 appnope==0.1.0
decorator==4.0.9 decorator==4.0.9
Django==1.9.2 Django==1.9.2
django-instapush==1.0.1 django-instapush==1.0.3
gnureadline==6.3.3 gnureadline==6.3.3
ipython==4.1.1 ipython==4.1.1
ipython-genutils==0.1.0 ipython-genutils==0.1.0
Expand Down
68 changes: 0 additions & 68 deletions temp/pushcert.pem

This file was deleted.

0 comments on commit 81f5c8d

Please sign in to comment.