Push notifications not working in production with iOS

That’s good to hear. I’m really hoping to not have to eject. That would probably add a few weeks on to our schedule. Here is the code we’re using:

Client side:

export const registerForPushNotifications = async () => {
  // Check for existing permissions
  const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS);
  let finalStatus = existingStatus;

  // If no existing permission, ask for permission:
  // Only ask if permissions have not already been determined, because
  // iOS won't necessarily prompt the user a second time.
  if (existingStatus !== 'granted') {
    // Android remote notification permissions are granted during the app
    // install, so this will only ask on iOS
    const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
    finalStatus = status;
  }

  // Stop here if the user did not grant permissions
  if (finalStatus !== 'granted') {
    return false;
  }

  // Get the token that uniquely identifies this device
  const token = await Notifications.getExpoPushTokenAsync();

  // Save the setting on the user object
  api.updateUser({
    expoPushToken: token,
    isPushNotificationsEnabled: true,
  });

  return true;
};

The updateUser simply saves the push notification string in the firebase database. As stated above it looks like this ‘ExponentPushToken[WEKAh7OXQjQOfVazIEHRi2]’

I’ve checked the settings on the app and all notifications are enabled after that client code is run.

The server side code then looks like this. These are the relevant lines. It’s node on firebase functions, but there are no connection problems:

const { Expo } = require('expo-server-sdk');
let expo = new Expo();

...
var pMessages = [];
const pushToken = userData.expoPushToken; // coming from firebase 'ExponentPushToken[WEKAh7OXQjQOfVazIEHRi2]'
pMessages.push({
                to: pushToken,
                sound: 'default',
                title: 'You have received a new message',
                body: 'Open chat to view',
                data: {type:'message',from: userName},
                badge: 1
              })
expo.sendPushNotificationsAsync(pMessages);

I’ve also tried sending push manually and getting a receipt. The receipt looks like this:

{"data":{"ca14c5a2-908c-4fd7-9806-47cf81874888":{"status":"error","message":"The Apple Push Notification service unexpectedly dropped the connection. Retry sending the notification later.","details":{"sentAt":1549139249},"__debug":{"internalError":"stream ended unexpectedly"}}}}

This is also an issue on the expo forum by another user here: IOS push notification dropped by server ("The Apple Push Notification service unexpectedly dropped the connection") · Issue #2185 · expo/expo · GitHub

But I did not start that issue so I’d like to try and solve it here as well. Expo manages my keys and I don’t want to do build:ios --clear if it’s going to delete my key. Also I don’t want to jump to submitting a new build to Apple unless absolutely necessary as the approval process for a new release takes several days and that’s a long time to wait for a guess. Any ideas?

*Also wanted to remind that all of this works on expo container app, but not stand alone or testflight so I can try something there. Also I’ve retrieved a new expoPushToken in the standalone so I’m not using the same push token as inside the container app.

*Also would the section of building standalone apps called “Switch to Push Notification Key on iOS” help any? What does --clear-push-cert do?