ota server change

This commit is contained in:
tapframe 2025-12-29 13:44:44 +05:30
parent b4b8648e25
commit e543d72879
4 changed files with 38 additions and 39 deletions

View file

@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="dev.jdtech.mpv"/> <uses-sdk tools:overrideLibrary="dev.jdtech.mpv"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
@ -22,7 +21,7 @@
<meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/> <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="@string/expo_runtime_version"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ERROR_RECOVERY_ONLY"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ERROR_RECOVERY_ONLY"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="30000"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="30000"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://grim-reyna-tapframe-69970143.koyeb.app/api/manifest"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://ota.nuvioapp.space/api/manifest"/>
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|locale|layoutDirection" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="unspecified"> <activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode|locale|layoutDirection" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="unspecified">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>

View file

@ -96,7 +96,7 @@
"enabled": true, "enabled": true,
"checkAutomatically": "ON_ERROR_RECOVERY", "checkAutomatically": "ON_ERROR_RECOVERY",
"fallbackToCacheTimeout": 30000, "fallbackToCacheTimeout": 30000,
"url": "https://grim-reyna-tapframe-69970143.koyeb.app/api/manifest" "url": "https://ota.nuvioapp.space/api/manifest"
}, },
"runtimeVersion": "1.3.2" "runtimeVersion": "1.3.2"
} }

View file

@ -11,6 +11,6 @@
<key>EXUpdatesRuntimeVersion</key> <key>EXUpdatesRuntimeVersion</key>
<string>1.2.11</string> <string>1.2.11</string>
<key>EXUpdatesURL</key> <key>EXUpdatesURL</key>
<string>https://grim-reyna-tapframe-69970143.koyeb.app/api/manifest</string> <string>https://ota.nuvioapp.space/api/manifest</string>
</dict> </dict>
</plist> </plist>

View file

@ -18,7 +18,7 @@ export class UpdateService {
private readonly MAX_LOGS = 100; // Keep last 100 logs private readonly MAX_LOGS = 100; // Keep last 100 logs
private updateCheckCallbacks: UpdateCheckCallback[] = []; private updateCheckCallbacks: UpdateCheckCallback[] = [];
private constructor() {} private constructor() { }
public static getInstance(): UpdateService { public static getInstance(): UpdateService {
if (!UpdateService.instance) { if (!UpdateService.instance) {
@ -104,11 +104,11 @@ export class UpdateService {
*/ */
public async testUpdateConnectivity(): Promise<boolean> { public async testUpdateConnectivity(): Promise<boolean> {
this.addLog('Testing update server connectivity...', 'INFO'); this.addLog('Testing update server connectivity...', 'INFO');
try { try {
const updateUrl = this.getUpdateUrl(); const updateUrl = this.getUpdateUrl();
this.addLog(`Testing URL: ${updateUrl}`, 'INFO'); this.addLog(`Testing URL: ${updateUrl}`, 'INFO');
const response = await fetch(updateUrl, { const response = await fetch(updateUrl, {
method: 'GET', method: 'GET',
headers: { headers: {
@ -118,13 +118,13 @@ export class UpdateService {
'expo-api-version': '1', 'expo-api-version': '1',
}, },
}); });
this.addLog(`Response status: ${response.status}`, 'INFO'); this.addLog(`Response status: ${response.status}`, 'INFO');
this.addLog(`Response headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}`, 'INFO'); this.addLog(`Response headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}`, 'INFO');
if (response.ok) { if (response.ok) {
this.addLog('Update server is reachable', 'INFO'); this.addLog('Update server is reachable', 'INFO');
// Try to get the response body to see what we're getting // Try to get the response body to see what we're getting
try { try {
const responseText = await response.text(); const responseText = await response.text();
@ -132,7 +132,7 @@ export class UpdateService {
} catch (bodyError) { } catch (bodyError) {
this.addLog(`Could not read response body: ${bodyError instanceof Error ? bodyError.message : String(bodyError)}`, 'WARN'); this.addLog(`Could not read response body: ${bodyError instanceof Error ? bodyError.message : String(bodyError)}`, 'WARN');
} }
return true; return true;
} else { } else {
this.addLog(`Update server returned error: ${response.status} ${response.statusText}`, 'ERROR'); this.addLog(`Update server returned error: ${response.status} ${response.statusText}`, 'ERROR');
@ -150,15 +150,15 @@ export class UpdateService {
*/ */
public async testAssetUrl(assetUrl: string): Promise<boolean> { public async testAssetUrl(assetUrl: string): Promise<boolean> {
this.addLog(`Testing asset URL: ${assetUrl}`, 'INFO'); this.addLog(`Testing asset URL: ${assetUrl}`, 'INFO');
try { try {
const response = await fetch(assetUrl, { const response = await fetch(assetUrl, {
method: 'HEAD', // Use HEAD to avoid downloading the full asset method: 'HEAD', // Use HEAD to avoid downloading the full asset
}); });
this.addLog(`Asset response status: ${response.status}`, 'INFO'); this.addLog(`Asset response status: ${response.status}`, 'INFO');
this.addLog(`Asset response headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}`, 'INFO'); this.addLog(`Asset response headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}`, 'INFO');
if (response.ok) { if (response.ok) {
this.addLog('Asset URL is accessible', 'INFO'); this.addLog('Asset URL is accessible', 'INFO');
return true; return true;
@ -178,17 +178,17 @@ export class UpdateService {
*/ */
public async testAllAssetUrls(): Promise<void> { public async testAllAssetUrls(): Promise<void> {
this.addLog('Testing all asset URLs from latest update...', 'INFO'); this.addLog('Testing all asset URLs from latest update...', 'INFO');
try { try {
const update = await Updates.checkForUpdateAsync(); const update = await Updates.checkForUpdateAsync();
if (!update.isAvailable || !update.manifest) { if (!update.isAvailable || !update.manifest) {
this.addLog('No update available or no manifest found', 'WARN'); this.addLog('No update available or no manifest found', 'WARN');
return; return;
} }
this.addLog(`Found update with ${update.manifest.assets?.length || 0} assets`, 'INFO'); this.addLog(`Found update with ${update.manifest.assets?.length || 0} assets`, 'INFO');
if (update.manifest.assets && update.manifest.assets.length > 0) { if (update.manifest.assets && update.manifest.assets.length > 0) {
for (let i = 0; i < update.manifest.assets.length; i++) { for (let i = 0; i < update.manifest.assets.length; i++) {
const asset = update.manifest.assets[i]; const asset = update.manifest.assets[i];
@ -203,7 +203,7 @@ export class UpdateService {
} }
} }
} }
// Test launch asset (check if it exists in the manifest) // Test launch asset (check if it exists in the manifest)
const manifest = update.manifest as any; // Type assertion to access launchAsset const manifest = update.manifest as any; // Type assertion to access launchAsset
if (manifest.launchAsset?.url) { if (manifest.launchAsset?.url) {
@ -215,7 +215,7 @@ export class UpdateService {
} else { } else {
this.addLog('No launch asset URL found', 'ERROR'); this.addLog('No launch asset URL found', 'ERROR');
} }
} catch (error) { } catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error); const errorMessage = error instanceof Error ? error.message : String(error);
this.addLog(`Failed to test asset URLs: ${errorMessage}`, 'ERROR'); this.addLog(`Failed to test asset URLs: ${errorMessage}`, 'ERROR');
@ -292,25 +292,25 @@ export class UpdateService {
this.addLog(`Runtime version: ${Updates.runtimeVersion || 'unknown'}`, 'INFO'); this.addLog(`Runtime version: ${Updates.runtimeVersion || 'unknown'}`, 'INFO');
this.addLog(`Platform: ${Platform.OS}`, 'INFO'); this.addLog(`Platform: ${Platform.OS}`, 'INFO');
this.addLog(`Updates enabled: ${Updates.isEnabled}`, 'INFO'); this.addLog(`Updates enabled: ${Updates.isEnabled}`, 'INFO');
try { try {
// Always attempt the check for debugging purposes // Always attempt the check for debugging purposes
this.addLog('Calling Updates.checkForUpdateAsync()...', 'INFO'); this.addLog('Calling Updates.checkForUpdateAsync()...', 'INFO');
const startTime = Date.now(); const startTime = Date.now();
const update = await Updates.checkForUpdateAsync(); const update = await Updates.checkForUpdateAsync();
const duration = Date.now() - startTime; const duration = Date.now() - startTime;
this.addLog(`Update check completed in ${duration}ms`, 'INFO'); this.addLog(`Update check completed in ${duration}ms`, 'INFO');
this.addLog(`Check result - isAvailable: ${update.isAvailable}`, 'INFO'); this.addLog(`Check result - isAvailable: ${update.isAvailable}`, 'INFO');
if (update.isAvailable) { if (update.isAvailable) {
this.addLog(`Update available! ID: ${update.manifest?.id || 'unknown'}`, 'INFO'); this.addLog(`Update available! ID: ${update.manifest?.id || 'unknown'}`, 'INFO');
if (update.manifest) { if (update.manifest) {
this.addLog(`Manifest ID: ${update.manifest.id || 'unknown'}`, 'INFO'); this.addLog(`Manifest ID: ${update.manifest.id || 'unknown'}`, 'INFO');
} }
// Check if we can actually install updates // Check if we can actually install updates
if (__DEV__) { if (__DEV__) {
this.addLog('WARNING: Update found but in development mode - installation will be skipped', 'WARN'); this.addLog('WARNING: Update found but in development mode - installation will be skipped', 'WARN');
@ -319,7 +319,7 @@ export class UpdateService {
} else { } else {
this.addLog('Update found and installation is possible', 'INFO'); this.addLog('Update found and installation is possible', 'INFO');
} }
return { return {
isAvailable: true, isAvailable: true,
manifest: update.manifest, manifest: update.manifest,
@ -343,7 +343,7 @@ export class UpdateService {
*/ */
public async downloadAndInstallUpdate(): Promise<boolean> { public async downloadAndInstallUpdate(): Promise<boolean> {
this.addLog('Starting update download and installation...', 'INFO'); this.addLog('Starting update download and installation...', 'INFO');
try { try {
// Check environment and updates status first // Check environment and updates status first
if (__DEV__) { if (__DEV__) {
@ -363,25 +363,25 @@ export class UpdateService {
this.addLog(`Update URL: ${this.getUpdateUrl()}`, 'INFO'); this.addLog(`Update URL: ${this.getUpdateUrl()}`, 'INFO');
this.addLog(`Runtime version: ${Updates.runtimeVersion || 'unknown'}`, 'INFO'); this.addLog(`Runtime version: ${Updates.runtimeVersion || 'unknown'}`, 'INFO');
this.addLog(`Platform: ${Platform.OS}`, 'INFO'); this.addLog(`Platform: ${Platform.OS}`, 'INFO');
const update = await Updates.checkForUpdateAsync(); const update = await Updates.checkForUpdateAsync();
if (update.isAvailable) { if (update.isAvailable) {
this.addLog(`Update found, starting download. ID: ${update.manifest?.id || 'unknown'}`, 'INFO'); this.addLog(`Update found, starting download. ID: ${update.manifest?.id || 'unknown'}`, 'INFO');
this.addLog(`Manifest details: ${JSON.stringify(update.manifest, null, 2)}`, 'INFO'); this.addLog(`Manifest details: ${JSON.stringify(update.manifest, null, 2)}`, 'INFO');
const downloadStartTime = Date.now(); const downloadStartTime = Date.now();
this.addLog('Calling Updates.fetchUpdateAsync()...', 'INFO'); this.addLog('Calling Updates.fetchUpdateAsync()...', 'INFO');
try { try {
await Updates.fetchUpdateAsync(); await Updates.fetchUpdateAsync();
const downloadDuration = Date.now() - downloadStartTime; const downloadDuration = Date.now() - downloadStartTime;
this.addLog(`Update downloaded successfully in ${downloadDuration}ms`, 'INFO'); this.addLog(`Update downloaded successfully in ${downloadDuration}ms`, 'INFO');
this.addLog('Calling Updates.reloadAsync() to apply update...', 'INFO'); this.addLog('Calling Updates.reloadAsync() to apply update...', 'INFO');
await Updates.reloadAsync(); await Updates.reloadAsync();
this.addLog('Update installation completed successfully', 'INFO'); this.addLog('Update installation completed successfully', 'INFO');
return true; return true;
} catch (fetchError) { } catch (fetchError) {
@ -412,7 +412,7 @@ export class UpdateService {
this.addLog('Getting current update info...', 'INFO'); this.addLog('Getting current update info...', 'INFO');
this.addLog(`Updates.isEnabled: ${Updates.isEnabled}`, 'INFO'); this.addLog(`Updates.isEnabled: ${Updates.isEnabled}`, 'INFO');
this.addLog(`Updates.isEmbeddedLaunch: ${Updates.isEmbeddedLaunch}`, 'INFO'); this.addLog(`Updates.isEmbeddedLaunch: ${Updates.isEmbeddedLaunch}`, 'INFO');
if (__DEV__) { if (__DEV__) {
this.addLog('In development mode - update info may not be accurate', 'WARN'); this.addLog('In development mode - update info may not be accurate', 'WARN');
} }
@ -430,7 +430,7 @@ export class UpdateService {
}; };
this.addLog(`Current update info - Available: ${info.isAvailable}, Embedded: ${info.isEmbeddedLaunch}`, 'INFO'); this.addLog(`Current update info - Available: ${info.isAvailable}, Embedded: ${info.isEmbeddedLaunch}`, 'INFO');
if (info.manifest) { if (info.manifest) {
this.addLog(`Current manifest ID: ${info.manifest.id || 'unknown'}`, 'INFO'); this.addLog(`Current manifest ID: ${info.manifest.id || 'unknown'}`, 'INFO');
} else { } else {
@ -469,7 +469,7 @@ export class UpdateService {
*/ */
public getUpdateUrl(): string { public getUpdateUrl(): string {
// Use the URL from app.json configuration // Use the URL from app.json configuration
return 'https://grim-reyna-tapframe-69970143.koyeb.app/api/manifest'; return 'https://ota.nuvioapp.space/api/manifest';
} }
/** /**