Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): update apple-app-site-association #2137

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions web/flat-web/deploy/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ http {
root /app;

location ~ ^/assets.+$ {
gzip on;
gzip_static on;
gzip_types application/javascript application/x-javascript text/javascript;
gzip on;
gzip_static on;
gzip_types application/javascript application/x-javascript text/javascript;

add_header Cache-Control "public, max-age=31536000";
try_files $uri 404;
add_header Cache-Control "public, max-age=31536000";
try_files $uri 404;
}

location /apple-app-site-association {
location /.well-known/apple-app-site-association {
add_header Content-Type 'application/json; charset=utf-8';
add_header Cache-Control no-cache;

Expand Down
18 changes: 13 additions & 5 deletions web/flat-web/public/apple-app-site-association.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"applinks": {
"apps": [],
"details": [
{
"appID": "48TB6ZZL5S.io.agora.flat",
"paths": [
"/join/*",
"/replay/*"
"appIDs": [
"48TB6ZZL5S.io.agora.flat",
"48TB6ZZL5S.io.agora.flint"
],
"components": [
{
"/": "/join/*",
"comment": "Join classroom link."
},
{
"/": "/replay/*",
"comment": "Replay classroom link."
}
]
}
]
Expand Down
23 changes: 6 additions & 17 deletions web/flat-web/scripts/vite-plugin-apple-app-site-association.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,14 @@ export function appleAppSiteAssociation(): Plugin {
}

const content = await readFile(file, "utf8");
const json = JSON.parse(content) as { applinks: { details: { appID: string }[] } };
const json = JSON.parse(content) as { applinks: { details: { appIDs: string[] }[] } };

json.applinks.details.forEach(detail => {
detail.appID = AppleAppID[region];
console.log("Updated apple-app-site-association.json:", detail.appID);
});

// Append all appIds to allow universal links for different region apps.
if (json.applinks.details.length > 0) {
const keys = Object.keys(AppleAppID) as (keyof typeof AppleAppID)[];
keys.forEach((key) => {
const appId = AppleAppID[key];
const appIdExist = json.applinks.details.some((detail) => detail.appID == appId);
if (!appIdExist) {
const appendingDetail = { ...json.applinks.details[0] };
appendingDetail.appID = appId;
json.applinks.details.push(appendingDetail);
}
});
if (region === "CN") {
json.applinks.details[0].appIDs = [AppleAppID["CN"], AppleAppID["SG"]];
} else if (region === "SG") {
json.applinks.details[0].appIDs = [AppleAppID["SG"], AppleAppID["CN"]];
}
}

await writeFile(file, JSON.stringify(json, null, 2), "utf8");
Expand Down
Loading