Skip to content

iOS: Activate and Deactivate events are not dispatched. #2046

@IriySoft

Description

@IriySoft

If you add event listeners for Activate/Deactivate on an iOS app, the events are not triggered when you switch between apps, lock the device or minimize the app:

Lib.current.stage.addEventListener(Event.DEACTIVATE, onDeactivate); // <== never triggers
Lib.current.stage.addEventListener(Event.ACTIVATE, onActivate); // <== triggers only once on app start-up

Same happens if you add the listeners to openfl.desktop.NativeApplication.nativeApplication or openfl.Lib.current.stage.nativeWindow. This can be tested with any app, including the Hello World Lime sample app by adding this code to the constructor:

Lib.current.stage.addEventListener(Event.DEACTIVATE, (_)->trace("Deactivated!"));

I found that the event is not dispatched by SDL that can be checked by adding a trace to handleWindowEvent() function of NativeApplication.hx, something like trace("Native App Window event: "+windowEventInfo.windowID); as the first line of the function. The trace is displayed for some events, like the device orientation change and such, but nothing happens when you lock/unlock the device or switch/minimize apps.

I believe this is connected with this issue: #1990

Looks like SDL needs update to version 3.4.0 minimum - this is the first SDL version that implements the scene-based UI lifecycle as required by Apple.

I managed to apply a patch to the current version of SDL (2.30.12) included in Lime, see the details here:

https://community.openfl.org/t/ios-activate-deactivate-events-dont-trigger/14454/15

This definitely doesn't look like a good solution, but I needed this badly to be able to build the iOS apps...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions