温馨提示:本文翻译自stackoverflow.com,查看原文请点击:ios - App Download from App Store got BadDeviceToken, build from source does not
apple-push-notifications django ios

ios - 从App Store下载App获得BadDeviceToken,从源代码构建没有

发布于 2020-04-28 21:59:34

我已经搜索了Stackoverflow,但没有一个回答我的问题,即从Xcode APNS进行构建有效,但是后端提出了App Store版本BadDeviceToken

Successregistration_id由从源代码制作

In [1]: APNSDevice.objects.all().send_message("test")
Out[1]:
[{'27321a3d872613499e27638733e9d1da7e6aa52888a2d90769b150f6339360b1': 'Success',
  '798a23a46169e405c41a0c9f44faa0acd39a65119960b973acd248a6de1d624e': 'Success',
  '1d742a9ae1684fed5e6c672587ee27c1523cc97e931cc64f108f7c4924aba2af': 'DeviceTokenNotForTopic',
  '27173de1aed3a065644708602fd5659cf4e0f8c3ce5b3ef7c4b0769655b92041': 'DeviceTokenNotForTopic',
  'e5647247877a0e1db3c7b52821b4230551267ca8a360f862ec5dde506e9b2f36': 'Success',
  '0eecae0cb6f4c27ee4b915e37dbb9c7cc84e4967e71c8efab808e231f46b8ec6': 'BadDeviceToken',
  '582d6a7c4628131cba9d0dfa9096cc81e3b48f6b6409252515d7402ef1c3ef30': 'BadDeviceToken'}]

我现在不在乎DeviceTokenNotForTopic只是专注于BadDeviceToken

复制步骤如下:

  1. 按照获取.p12文件
  2. 然后.pemdoc制作我必须把passphrasekey otherwise I can not proceed next step
  3. 从App Store下载我自己的应用并登录以获取 registration_id

检查:

  1. pushtry.com我上传.p12并放入registration_id我可以得到它的作品push notification

  2. openssl s_client -connect gateway.push.apple.com:2195 -cert aps-cert.pem -key aps-key-noenc.pem也可以没有任何问题。连接仍然存在

My configuration:
Django3
django-push-notification @master commit: c610dd9c7871f4e81bdffce783df8b040ca22878

settings.py

PUSH_NOTIFICATIONS_SETTINGS['APNS_CERTIFICATE'] = str(APPS_DIR) + '/push_noti/dd/aps.pem'
PUSH_NOTIFICATIONS_SETTINGS['APNS_USE_SANDBOX'] = "gateway.push.apple.com:2195"
PUSH_NOTIFICATIONS_SETTINGS['APNS_TOPIC'] = "com.multy.herr.reviews"

I had tried with the same production APNS cert according to this

Development server: api.sandbox.push.apple.com:443
Production server: api.push.apple.com:443

However, all giving me same BadDevieToken

FYI:
I am using production APNS cert

I take care only Django backend. My iOS developer upload app from his computer. I am not sure this will be problematic or not

I had tried fastlane with pushtry.com again .p12 works, but .pem does not. It pop up dialog production_com.xxx.yyy.zzz.pem | 3883 | application/x-x509-ca-cert

Question:

Where am I wrong?

Another Solution:
I might use AWS SNS to deal with this

查看更多

提问者
Sarit
被浏览
15
Sarit 2020-02-13 12:21

@Wyetro is correct. The problem comes from that line I was confused with document and codebase at certain level in the lib itself it use bool

PUSH_NOTIFICATIONS_SETTINGS['APNS_USE_SANDBOX'] = False

Then I can be able to send out message