Search Unity

Resolved Not Receiving iOS Push Notifications

Discussion in 'Player Engagement' started by MiTschMR, Apr 10, 2023.

  1. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    494
    I am using PN version 3.0.1-pre.1, configured the key, team ID and everything else in the dashboard and set up the application for registering with the service. The XCode console tells me that the register process went great, returned a token, but for the love of p I can't my device get to receive any of the notifications. May that be with a scheduled one, returning or the device token for testing, it always fails. The analytics dashboard tells me the following message:


    Error sending to APNS, HTTP status 400, error message: The specified device token is invalid. Verify that the request contains a valid token and that the token matches the environment.


    I tried with the bundle identifier for my game, the one for the notificationservice (ending with *.notificationservice), nothing. Deleted everything, readded, nothing. Very grateful for any guidance who completed it for iOS...
     
  2. mforrest44

    mforrest44

    Unity Technologies

    Joined:
    Apr 9, 2021
    Posts:
    29
    Hey!

    Sorry to hear you're having trouble getting set up with Push Notifications.There are two likely scenarios in which we'd expect to see this error:
    • The device token wasn't correctly entered
    • The build environment of the app and device token does not match the environment of the certificate entered in the dashboard (sandbox/development vs production)
    It's more than likely the latter. If you are using a production key/certificate, please make sure you've disabled sandbox when uploading the key/certificate in the dashboard. You should also ensure you're using the production build of your app.

    If it's a development key/certificate. ensure sandbox is enabled during upload and you're testing against the development build of your app.

    I hope that helps! Let me know if you have any further questions.

    Mike
     
  3. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    494
    Hi Mike

    thanks a lot for your answer. I think my bad is that I confused sandbox/development with a development build of the Unity editor project, not with an Xcode debug build! I didn’t know it does a debug build and that you can switch it to release.

    Will try that this evening and let you know:cool:
     
  4. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    494
    Nope, can't get it to work. Removed everything, gave it a new identifier, added the key etc. Nothing.

    I changed the XCode scheme from debug to release, meaning it won't be Sandbox (from my understanding). Nothing. Did it the other way round. Nothing.

    In the identifier in the Apple developer portal, do I need to create the SSL certificates for the connections? I did that in the first run, but it did nothing. Now I left it empty and it still doesn't work. Followed the guide, it doesn't mention anything about them, so I guess these are not required.

    I mean, it is not even funny anymore. It can't be that difficult... Will create another new project tomorrow that only calls the PN services and nothing else and see if that works...
     
  5. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    494
    Got it to work, needed to change the scheme on every target (Unity-iPhone, notificationsservice etc.) in the run section from debug to release and then do a testing build to get it to work with the sandbox environment. My god, what a journey that was...
     
  6. mforrest44

    mforrest44

    Unity Technologies

    Joined:
    Apr 9, 2021
    Posts:
    29
    Hey!

    Glad to hear you got things fixed and I'm really sorry we couldn't provide better troubleshooting steps.

    If you have any further questions now that you have the SDK implemented please don't hesitate to let us know!

    We'll make sure to capture the issues you came up against for reference by future customers.

    Thanks and apologies again,

    Mike
     
    SebT_Unity likes this.