Testing remote notifications with simulator

Greetings everyone,

we have a problem testing remote notifications to our app runing in an iOS simulator, which should be possible for quite a while now. (https://nilcoalescing.com/blog/TestingRemotePushOniOSSimulator/)

We made sure of the following prerequisites

  1. The system requirements (recent XCode, recent MacOS, Silicone Processor) are met
  2. The app build is set to testing
  3. The app is in fact generating a devicetoken and sendig it to our backend
  4. We are sending our requests to the api.sandbox.push.app.com environment

Nonetheless, we always receive a status 400, error "BadDeviceToken" response from the APNS service.

Doing the same with a physical device works like a charm, ie the message is received without any problems.

We also tried sending the same device token to a production environment, but got the same 400/BadDeviceToken error. Also the simulator-generated token does not look distorted, ie it's also just a HEX string with the same length as the working token of the physical device.

Is there anything else we need to check for this to work?

Accepted Reply

While we would need to see the actual token to examine and see if there is problem with it, if you are seeing the simulator token to be the same length as a physical device, there could be a mistake when converting it. We expect the simulator tokens to be longer HEX strings. Make sure your code serializing the token data into a HEX string is not assuming a certain length.

  • Thanks for your reply. Yes, that was the issue. Came to the same, when reading the respective section in the XCode release nodes again and then reviewed our code, which of course did only take the first 32 bytes of the token ... (probably based on some answer from stackoverflow, originating, years back ...)

Add a Comment

Replies

While we would need to see the actual token to examine and see if there is problem with it, if you are seeing the simulator token to be the same length as a physical device, there could be a mistake when converting it. We expect the simulator tokens to be longer HEX strings. Make sure your code serializing the token data into a HEX string is not assuming a certain length.

  • Thanks for your reply. Yes, that was the issue. Came to the same, when reading the respective section in the XCode release nodes again and then reviewed our code, which of course did only take the first 32 bytes of the token ... (probably based on some answer from stackoverflow, originating, years back ...)

Add a Comment