- Whether you are bare or managed workflow: bare
- Your
eas-cli
version: 0.55.1
Hi everyone, I am getting the following “'Could not find APNs credentials” error when I try sending push notifications through the backend:
[
{
status: 'error',
message: 'Could not find APNs credentials for [bundle] ([expo account/ bundle]). You may need to generate or upload new push credentials.',
details: { error: 'InvalidCredentials' }
}
]
This is my backend code that I run:
const { Expo } = require('expo-server-sdk');
let expo = new Expo();
let messages = [];
const somePushTokens = ["ExponentPushToken[FZLcomJcUxNieW642rDRQR]"];
for(let pushToken of somePushTokens){
if (!Expo.isExpoPushToken(pushToken)) {
console.error(`Push token ${pushToken} is not a valid Expo push token`);
continue;
}
messages.push({
to: pushToken,
sound: 'default',
body: 'This is a test notification',
data: { withSome: 'data' },
})
}
let chunks = expo.chunkPushNotifications(messages);
let tickets = [];
(async () => {
for (let chunk of chunks) {
try {
let ticketChunk = await expo.sendPushNotificationsAsync(chunk);
console.log(ticketChunk);
tickets.push(...ticketChunk);
} catch (error) {
console.error(error);
}
}
})();
I got the Expo token from my app. The reason why I’m confused by the error is because through expo credentials:manager, I am able to successfully assign the Push Notification Key to my bundle:
✔ What do you want to do? › Use existing Push Notifications Key in current project
✔ Select credentials from list › Push Notifications Key (Key ID: [KEY ID], Team ID: [TEAM ID])
used by [expo account] ([bundle id])
❓ Validity of this certificate on Apple's servers is unknown.
Successfully assigned Push Notifactions Key to [expo account] ([bundle id])
I also checked in Apple Developer, and under Certificates, Identifiers & Profiles > Keys, the expo push notifications key is there with the matching KEY ID.
Does anyone have any thoughts on how I could resolve this issue?