Compare commits
2 Commits
f2a14ce23e
...
56f29b8306
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56f29b8306 | ||
|
|
7c1fbd6696 |
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user