wails/v3/pkg/application/application_ios_delegate.m
Lea Anthony 637713fae6 feat: adapt iOS and Android message processors to RuntimeRequest transport
Transport layer refactor adaptations for mobile platforms:

- Refactor processIOSMethod to use RuntimeRequest signature
- Refactor processAndroidMethod to use RuntimeRequest signature
- Add androidRequest constant (12) and handler to messageprocessor.go
- Update messageprocessor_mobile_stub.go for non-mobile builds
- Fix undefined windowID variable (use req.WebviewWindowID)
- Add iOS event generation to tasks/events/generate.go
- Add InvalidIOSCallError and InvalidAndroidCallError to errs package
- Update iOS delegate and webview files with generated event handlers

iOS methods refactored: Haptics.Impact, Device.Info, Scroll settings,
Navigation gestures, Link previews, Debug inspector, UserAgent

Android methods refactored: Haptics.Vibrate, Device.Info, Toast.Show

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 21:27:04 +11:00

83 lines
3.2 KiB
Objective-C

//go:build ios
#import "application_ios_delegate.h"
#import "../events/events_ios.h"
#import "application_ios.h"
extern void processApplicationEvent(unsigned int, void* data);
extern void processWindowEvent(unsigned int, unsigned int);
extern bool hasListeners(unsigned int);
@implementation WailsAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Set global appDelegate reference and bring up a window if needed
appDelegate = self;
if (self.window == nil) {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *rootVC = [[UIViewController alloc] init];
rootVC.view.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = rootVC;
[self.window makeKeyAndVisible];
}
// Apply app-wide background colour if configured
unsigned char r = 255, g = 255, b = 255, a = 255;
if (ios_get_app_background_color(&r, &g, &b, &a)) {
CGFloat fr = ((CGFloat)r) / 255.0;
CGFloat fg = ((CGFloat)g) / 255.0;
CGFloat fb = ((CGFloat)b) / 255.0;
CGFloat fa = ((CGFloat)a) / 255.0;
UIColor *color = [UIColor colorWithRed:fr green:fg blue:fb alpha:fa];
self.window.backgroundColor = color;
self.window.rootViewController.view.backgroundColor = color;
}
if (!self.viewControllers) {
self.viewControllers = [NSMutableArray array];
}
if (hasListeners(EventApplicationDidFinishLaunching)) {
processApplicationEvent(EventApplicationDidFinishLaunching, NULL);
}
return YES;
}
// GENERATED EVENTS START
- (void)applicationDidBecomeActive:(UIApplication *)application {
if( hasListeners(EventApplicationDidBecomeActive) ) {
processApplicationEvent(EventApplicationDidBecomeActive, NULL);
}
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
if( hasListeners(EventApplicationDidEnterBackground) ) {
processApplicationEvent(EventApplicationDidEnterBackground, NULL);
}
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
if( hasListeners(EventApplicationDidFinishLaunching) ) {
processApplicationEvent(EventApplicationDidFinishLaunching, NULL);
}
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
if( hasListeners(EventApplicationDidReceiveMemoryWarning) ) {
processApplicationEvent(EventApplicationDidReceiveMemoryWarning, NULL);
}
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
if( hasListeners(EventApplicationWillEnterForeground) ) {
processApplicationEvent(EventApplicationWillEnterForeground, NULL);
}
}
- (void)applicationWillResignActive:(UIApplication *)application {
if( hasListeners(EventApplicationWillResignActive) ) {
processApplicationEvent(EventApplicationWillResignActive, NULL);
}
}
- (void)applicationWillTerminate:(UIApplication *)application {
if( hasListeners(EventApplicationWillTerminate) ) {
processApplicationEvent(EventApplicationWillTerminate, NULL);
}
}
// GENERATED EVENTS END
@end