Unable to receive notifications on TestFlight, error: `stream ended unexpectedly`


#1

Hey folks,

So I’ve been battling trying to get notifications to work with my Expo project for over a week now, and I’m still not quite there. I’ve managed to get notifications working with the Expo app on local development, but once the app is deployed to TestFlight, notifications are no longer received and a generic error message is returned.

I’m using the following setup:

  • App is NOT ejected, it’s built with create-react-native-app and is still handled by Expo (deploy script listed towards the end)
  • Uses simple Node.js notifications script (basically this: https://github.com/expo/expo-server-sdk-node)

When attempting to notify any token that correspond to TestFlight installs, I get the following error message:

'[hash-of-receipt-id]':
   { status: 'error',
     message:
      'The Apple Push Notification service unexpectedly dropped the connection. Retry sending the notification later.',
     details: { sentAt: 1535131662 },
     __debug: { internalError: 'stream ended unexpectedly' } }

I do not get this error message developing locally with the Expo app.

I’m using the code from the example on the Node expo-server-sdk docs here for reference: https://github.com/expo/expo-server-sdk-node.

Just to re-iterate, I believe the script itself is fine, as it triggers notifications for Expo (local dev server on my mac) but fails when the app is installed via TestFlight (we’re still in testing so haven’t progressed to an app listing on the App Store yet, so can’t comment on if the issue persists there too).

Outside of the notifications script (which I don’t think is the source of the problem but may be wrong), my deploy script is based on this post on the Expo blog: https://blog.expo.io/automating-standalone-expo-app-builds-and-deployments-with-fastlane-exp-and-exptool-9b2f5ad0a2cd#714b

So I think that should deploy to TestFlight in the manner Expo expects (which makes me wonder where the issue really is?). Might I have missed a key step to get app’s distributed with TestFlight working? I’ve not seen that in the docs if so.

Worth noting, I have tweaked a few things in Xcode as I tried to get OneSignal working before I realised that wasn’t possible without ejecting. This is my first mobile app project so I’m naive when it comes to what might be the cause of this problem.

Any help or direction to proceed here would be much appreciated as I’m at the point where I might recreate a whole new project and go through the process of submitting to Apple again just to see if a fresh build would work, but that would be a fair amount of hassle.

If you read this far, thanks :pray:

EDIT: Someone mentioned it might be a certificate problem. Does that sound right? Will investigate that, but please let me know if you have thoughts about other potential causes here!


#2

The error “The Apple Push Notification service unexpectedly dropped the connection.” indicates an issue sending the notification to Apple. Speaking generally, there are at least three categories of the error:

  • Something wrong with Apple: try again later
  • Something wrong with the device token (e.g. sending notifications to a device token to which Apple has asked you to stop sending notifications): uninstall and reinstall your app and see if that fixes things with the new device token.
  • Something wrong with the push service credentials: clear your credentials with exp build:ios -c and let Expo regenerate new ones. (The device tokens are independent from the credentials.)

#3

@ide you are a legend! The third option, running exp build:ios -c and re-entering credentials (including deleting old certs from https://developer.apple.com/account/ did the trick. Thank you so much for your help here!

If there’s a charity that means a lot to you, I’ll happily make a small donation as a way of saying thanks for your help here. Feel free to let me know here or DM on twitter (@fredrivett).


closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.