Skip to content

Commit

Permalink
j
Browse files Browse the repository at this point in the history
  • Loading branch information
vince-hz committed Mar 21, 2024
1 parent 373600d commit 896f513
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
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

0 comments on commit 896f513

Please sign in to comment.