Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone push notifications passphrase issue (pyAPns)

I'm trying to implement push notifications for iphone based on PyAPNs

When I run it on local but it blocks and prompts me to enter the passphrase manually and doesn't work until I do

I don't know how to set it up so to work without prompt

This is my code:

from apns import APNs, Payload
import optparse
import os


certificate_file = here(".." + app.fichier_PEM.url   )        
token_hex = '0c99bb3d077eeacdc04667d38dd10ca1a'
pass_phrase = app.mot_de_passe



apns = APNs(use_sandbox=True, cert_file= certificate_file)
payload = Payload(alert = message.decode('utf-8'), sound="default", badge=1)
apns.gateway_server.send_notification(token_hex, payload)


# Get feedback messages
for (token_hex, fail_time) in apns.feedback_server.items():
    print "fail: "+fail_time
like image 576
Armance Avatar asked Dec 04 '13 09:12

Armance


People also ask

Does iOS Chrome support push notifications?

Chrome doesn't get notifications on your iPhone or iPad. If you get any alerts from Chrome, you may have pop-ups enabled.

How do I use Apple push notifications for APN?

Use the location push type for notifications that request a user's location. If you set this push type, the apns-topic header field must use your app's bundle ID with . location-query appended to the end. For more information, see Creating a Location Push Service Extension.


1 Answers

When you create a .pem file without phrase specify -nodes

To Create .pem file without phrase

openssl pkcs12 -nocerts -out Pro_Key.pem -in App.p12 -nodes

To Create .pem file with phrase

openssl pkcs12 -nocerts -out Pro_Key.pem -in App.p12

If you have a .pem file with password you can get rid of its password for PyAPNs using the following

openssl rsa -in haspassword.pem -out nopassword.pem

Refer

  • Raywenderlich
  • Apple Push Notification Step By Step Guide

for make certificates and other configurations.

Some Python library for interacting with the Apple Push Notification service (APNs)

  • djacobs->PyAPNs
  • samuraisam->pyapns
  • apns-client
like image 185
icodebuster Avatar answered Sep 23 '22 05:09

icodebuster