django-push-notifications icon indicating copy to clipboard operation
django-push-notifications copied to clipboard

APNSServerError DeviceTokenNotForTopic when upgrading

Open grokcode opened this issue 7 years ago • 10 comments

I recently upgraded django-push-notifications from 1.4.1 to 1.5.0, and added the new required APNS_TOPIC setting set to the bundle id. Everything is working fine for APNS devices created after the upgrade, but for devices created on 1.4.1, when attempting to send push notificiations to them, I am getting APNSServerError DeviceTokenNotForTopic .

Is there an upgrade path for those devices so I don't lose the ability to send pushes to them? Maybe some way to specify not to send a topic?

grokcode avatar Jun 14 '17 00:06 grokcode

Hello ! This was a mistake on our part, I made APNS_TOPIC optional again in https://github.com/jleclanche/django-push-notifications/pull/413 - this will let you not specify a topic again. I will let you know as soon as it's merged.

kit-cat avatar Jun 21 '17 20:06 kit-cat

Hello! Can you please upgrade to master and try sending messages without APNS_TOPIC settings? It should work again, I just merged the APNS_TOPIC not mandatory anymore PR

kit-cat avatar Jul 18 '17 16:07 kit-cat

@kit-cat 2 years by now. Any answer on this problem?

elcolie avatar Jul 27 '19 04:07 elcolie

Found the answer My settings.py is using production certificate, but for now I need to enable DEBUG=True. The main problem comes from APNS_TOPIC is not the same as in the Apple website

DEBUG=True
PUSH_NOTIFICATIONS_SETTINGS['USE_SANDBOX'] = False
PUSH_NOTIFICATIONS_SETTINGS['APNS_USER_SANDBOX'] = 'api.push.apple.com'
PUSH_NOTIFICATIONS_SETTINGS['APNS_CERTIFICATE'] = str(APPS_DIR) + '/push_noti/prod-cert.pem'
PUSH_NOTIFICATIONS_SETTINGS['APNS_TOPIC'] = "com.mycompany.xxx"

elcolie avatar Jul 27 '19 04:07 elcolie

Hi @elcolie, I haven't worked on this repo for years - can you please try pinging an active maintainer? Thanks!

kit-cat avatar Jul 27 '19 12:07 kit-cat

@odinuge @wtayyeb Without DEBUG=True I can not send out push notification DEBUG=False will raises Stream problem.

One big problem right now is django-push-notification always let sentry sends out the crash report.

Reference issue

elcolie avatar Jul 27 '19 16:07 elcolie

Digging in settings.py found that settings.py#L25 APNS_USE_SANDBOX is same as DEBUG if not explicitly set. you must add APNS_USE_SANDBOX=False to PUSH_NOTIFICATIONS_SETTINGS in your settings.py file to solve the problem.

PS:

  1. I'm not a maintainer, and just have 2 PR merged!
  2. GitHub is limiting my account because I`m in Iran. What they think about me?
  3. there is no settings named APNS_USER_SANDBOX as you mentioned in your comment and APNS_USE_SANDBOX is used as boolean

wtayyeb avatar Jul 27 '19 19:07 wtayyeb

@elcolie I don't plan to send APN messages yet, but in case of sentry I have it enabled for development and production deploys beside django-push-notification and don't have your problem.

wtayyeb avatar Jul 27 '19 19:07 wtayyeb

I am confused What is the correct value of APNS_USE_SANDBOX ? Access time Sun Jul 28 12:59:17 +07 2019 Pasted_Image_28_7_19_12_58

elcolie avatar Jul 28 '19 05:07 elcolie

After check with source code. Document is outdated

elcolie avatar Jul 28 '19 06:07 elcolie