Skip to content

v2.0.0 - NativePHP Mobile v4

Latest

Choose a tag to compare

@SRWieZ SRWieZ released this 24 Aug 13:51

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 FakeBridge a 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 BrightnessChanged event. They existed before but were not documented anywhere.

Changed

  • Breaking: keepAwake() and allowSleep() now answer one simple question: "did it work?" — true means yes, false means no. Before, keepAwake(false) returned the new wake-lock state, so a successful call confusingly returned false. If you were checking the return value of keepAwake(false), flip your logic: true now 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 returns false in that case.
  • On Android, when the system brightness could not be read, getBrightness() returned -1.0. That was never a valid brightness. You now get null, exactly as the docs always promised.
  • Two README mistakes: the install notes mentioned a MobileScreenServiceProvider class that does not exist (the real one is ScreenServiceProvider), 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