I attempted to use the new App Store Connect API 3.0 feature to manage Game Center achievements. My goal was to create a bunch of achievements, with one en-US localization each, with an attached image.
Creating the achievement and its localization initially seems to have worked fine; I uploaded the image, and its assetDeliveryState.state
is COMPLETED
. But when I visit the achievement in the App Store Connect Console UI, all the images I've uploaded are 404 Not Found. I'm going to have to upload all of these images by hand. 😭
Here's the sample code I used, using the https://github.com/dfabulich/node-app-store-connect-api v5.0.3.
import { api } from 'node-app-store-connect-api';
import { readFile, stat } from 'node:fs/promises';
import { homedir } from 'node:os';
const appId = 6468677114;
const vendorIdentifier = 'com.example.myachievement';
const showBeforeEarend = true;
const points = 10;
const locale = "en-US";
const title = "My Achievement";
const afterEarnedDescription = "Earned the achievment.";
const beforeEarnedDescription = "Earn the achievement.";
const fileName = `${vendorIdentifier}.png`;
const params = {
issuerId: "69a6de6f-0d6d-47e3-e053-5b8c7c11a4d1",
apiKey: "3S3G8T48YW",
};
params.privateKey = await readFile(`${homedir()}/.appstoreconnect/private_keys/AuthKey_${params.apiKey}.p8`, 'utf8');
const { read, create, uploadAsset, pollForUploadSuccess } = await api(params);
const {data: gameCenterDetail} = await read(`apps/${appId}/gameCenterDetail`);
console.log('creating', vendorIdentifier);
const gameCenterAchievement = await create({
type: 'gameCenterAchievements',
attributes: {
referenceName: title,
vendorIdentifier,
points,
repeatable: false,
showBeforeEarned,
},
relationships: { gameCenterDetail }
});
console.log(' localization');
const gameCenterAchievementLocalization = await create({
type: 'gameCenterAchievementLocalizations',
attributes: {
locale,
name: title,
afterEarnedDescription,
beforeEarnedDescription,
},
relationships: { gameCenterAchievement }
});
console.log(' image');
const image = await create({
type: 'gameCenterAchievementImages',
attributes: {
fileName,
fileSize: (await stat(fileName)).size,
},
relationships: {
gameCenterAchievementLocalization
}
});
console.log(' upload');
await uploadAsset(image, await readFile(fileName));
console.log(' poll');
await pollForUploadSuccess(image.links.self);