Compare commits

...

2 Commits

Author SHA1 Message Date
Hamza-Ayed
56f29b8306 fix: stabilize iOS launch and remove SceneDelegate dependency 2026-05-18 16:41:16 +03:00
Hamza-Ayed
7c1fbd6696 fix: add retry & delay to downloadMedia in server.js 2026-05-18 16:41:12 +03:00
3 changed files with 24 additions and 35 deletions

View File

@@ -2,19 +2,13 @@ import Flutter
import UIKit
@main
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if self.window == nil {
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.rootViewController = UIViewController()
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)
GeneratedPluginRegistrant.register(with: self)
return result
}
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
}
}
}

View File

@@ -26,27 +26,6 @@
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>UIWindowScene</string>
<key>UISceneConfigurationName</key>
<string>flutter</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>

View File

@@ -388,9 +388,25 @@ async function handleMessage(ws, raw) {
}
console.log(`[WS] Downloading media for message: ${messageId}`);
const media = await msg.downloadMedia();
if (!media) {
return respond({ type: 'error', message: 'Failed to download media file from WhatsApp servers' });
let media = null;
// Attempt to download media with retries and a delay to allow decryption
for (let i = 0; i < 3; i++) {
try {
media = await msg.downloadMedia();
if (media && media.data) {
console.log(`[WS] Successfully downloaded media on attempt ${i + 1}`);
break;
}
} catch (err) {
console.warn(`[WS] Media download attempt ${i + 1} failed:`, err.message);
}
// Wait 1.5 seconds before retrying
await new Promise(resolve => setTimeout(resolve, 1500));
}
if (!media || !media.data) {
return respond({ type: 'error', message: 'Failed to download media file from WhatsApp servers after multiple attempts' });
}
return respond({