Что вызывает этот ответ BadDeviceToken в APNS?
Вот мой код, отправляющий apns:
@classmethod
def PingDevice(cls, devicetoken, pushmagic):
# Create the payload for the push notification
payload = Payload(custom={'mdm': pushmagic})
print("Payload:", payload)
print(f"device token: {devicetoken}")
# Path to your certificate
cert_path = os.path.join(settings.BASE_DIR, 'sign', "PushCert.pem")
print("Certificate Path:", cert_path)
# Load your certificate and private key
credentials = CertificateCredentials(cert_path)
print("Credentials:", credentials)
# Create an APNs client
apns_client = APNsClient(credentials=credentials, use_sandbox=False)
print("APNs Client:", apns_client)
# Send the push notification
try:
response = apns_client.send_notification(token_hex=devicetoken, notification=payload, topic='apns-topic')
if response == 'Success':
print("Push notification sent successfully")
else:
print(f"Failed to send notification: {response.description}")
except Exception as e:
print('Bad device token:', e)
Но я столкнулся с проблемой: вот ответ, который я получаю при печати кода на AWS:
Bad device token:
Я очень ценю любую помощь.