This release makes the plugin better support NativePHP Mobile v4. It still works with v3, so you can upgrade the plugin first and NativePHP later (nativephp/mobile: ^3.0|^4.0).
Added
-
You can now test screen behavior in your app without a device or simulator. On NativePHP Mobile v4, the plugin teaches the
FakeBridgea few helpers, so your tests read like plain English:use Native\Mobile\Testing\FakeBridge; // Pretend the device brightness is at 42% $bridge = FakeBridge::enable()->withBrightness(0.42); // ... run the code you want to test ... // Check what your app asked the screen to do $bridge->assertKeptAwake(); $bridge->assertBrightnessSet(1.0);
Also available:
assertSleepAllowed()(checks the wake lock was released). -
The plugin itself now has a real test suite. Every method is tested against a fake bridge — what gets sent, what comes back, and what happens when things fail. On NativePHP v3 these tests simply skip (the fake bridge is a v4 feature).
-
Tests now run automatically on GitHub for every push and pull request, on both NativePHP v3 (PHP 8.3) and v4 (PHP 8.4).
-
The README now explains the brightness listener and the
BrightnessChangedevent. They existed before but were not documented anywhere.
Changed
- Breaking:
keepAwake()andallowSleep()now answer one simple question: "did it work?" —truemeans yes,falsemeans no. Before,keepAwake(false)returned the new wake-lock state, so a successful call confusingly returnedfalse. If you were checking the return value ofkeepAwake(false), flip your logic:truenow means success. - Breaking: the plugin now requires PHP 8.3 or newer. In practice this changes nothing — NativePHP Mobile v3 already required PHP 8.3, so the old "PHP 8.2" claim could never actually be installed.
- Some internal cleanup in the iOS and Android code (fewer thread hops, removed unused state). Nothing changes in how the plugin behaves.
- The dev setup now accepts Pest 4 as well as Pest 3.
Fixed
allowSleep()used to say "success" even when the native bridge was not there at all (for example when running your app in a plain browser). It now correctly returnsfalsein that case.- On Android, when the system brightness could not be read,
getBrightness()returned-1.0. That was never a valid brightness. You now getnull, exactly as the docs always promised. - Two README mistakes: the install notes mentioned a
MobileScreenServiceProviderclass that does not exist (the real one isScreenServiceProvider), and the JavaScript example imported an npm package that was never published. The README now shows the import path that actually works.
Full Changelog: v1.1.0...v2.0.0