Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad device registration token #224

Open
pausanchezv opened this issue Mar 16, 2024 · 1 comment
Open

Bad device registration token #224

pausanchezv opened this issue Mar 16, 2024 · 1 comment

Comments

@pausanchezv
Copy link

pausanchezv commented Mar 16, 2024

It keeps saying "Bad device registration token". However, when sending the exact same thing directly from Firebase it works well. here's what I do:

@router.get("/push-notification-test", status_code=status.HTTP_200_OK, response_model=None)
async def test():

    client = ApnsClient(
        use_sandbox=True,
        team_id="XXXXXXX",
        auth_key_id="XXXXXXX",
        auth_key_filepath=f"{settings.base_dir}/AuthKey_XXXXXXX.p8",
    )

    registration_id = "XXXXXXXXXXXXX"

    payload_alert = PayloadAlert(title="YOUR TITLE", body="YOUR BODY")
    payload = Payload(alert=payload_alert, badge=1, sound="default")
    config = ApnsConfig(topic="xxx.xxx.xxxx")

    await client.send_message(
        device_token=registration_id,
        payload=payload,
        apns_config=config,
    )

Hope you can point me in the right direction. Thanks.

@nnsnodnb
Copy link
Owner

Let me first ask you a question about your current situation.

Is it correct that the registration_id is not from FirebaseMessaging but from the deviceToken obtained in application(_:didRegisterForRemoteNotificationsWithDeviceToken:) method of the UIApplicationDelegate? FCM tokens and APNs tokens are completely different and you cannot use FCM tokens as registration_id here.

Or are you specifying sandbox environment and production environment by mistake?

Can you check if the device token is correct from the command line from the documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants