You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Device not response on server url

Hi Everyone I'm Using this package to send MDM push notification




from apns2.client import APNsClient, NotificationType
from apns2.payload import Payload
def PingDevice(cls, devicetoken, pushmagic):
# Send request to Apple
print('Send request to Apple')
topic = "com.apple.mgmt.External.ff2ea8ba-350c-4e1d-9a0d-cf8f62c06086"
    # Path to your VoIP certificate
    cert_path = os.path.join(settings.BASE_DIR, 'sign', "PushCert.pem")

    # Initialize the client
    client = APNsClient(cert_path, use_sandbox=False, use_alternative_port=False)

    # Prepare the payload
    payload = Payload(custom={"mdm": pushmagic.decode('utf-8')})

    try:
        # Send the notification
        response = client.send_notification_async(token_hex=base64.b64decode(devicetoken).hex(), notification=payload, topic=topic,push_type=NotificationType.MDM)
        result = client.get_notification_result(response)

        print(f"Notification sent successfully: {result}")
        return True
    except Exception as e:
        print(f"Error sending notification: {e}")
        return False

notification was sent successfully but the device did not respond on my server URL please tell me why this happened.


iPhone XS Max

Posted on Nov 5, 2024 11:27 PM

Reply

There are no replies.

Device not response on server url

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.