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

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:

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: GitHub - expo/expo-server-sdk-node: Server-side library for working with Expo using Node.js.

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: Automating Standalone Expo App Builds and Deployments with Fastlane and Expo CLI | by Mark Glagola | Exposition

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!

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.)
1 Like

@ide you are a legend! The third option, running exp build:ios -c and re-entering credentials (including deleting old certs from Sign In - Apple 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).

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