rpwebdevelopment / webview-detect
Webview detection package
Fund package maintenance!
rpwebdevelopment
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/rpwebdevelopment/webview-detect
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
README
Package designed to handle parsing of User-Agent headers to determine if users are accessing applications vie WebView or not.
Installation
You can install the package via composer:
composer require rpwebdevelopment/webview-detect
Usage
Basic usage is as follows:
use RPWebDevelopment\WebviewDetect\Facades\WebviewDetect; $userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'; $isWebView = WebviewDetect::forUserAgent($userAgent)->isWebView();
Additionally we can initialise the facade with a request for simplified handling within controller/middleware classes:
namespace App\Http\Middleware; use Illuminate\Http\Request; use RPWebDevelopment\WebviewDetect\Facades\WebviewDetect; class FooMiddleware { public function handle(Request $request, Closure $next) { $isWebview = WebviewDetect::forRequest($request)->isWebView(); // business logic return $next($request); } }
Notes
While efforts have been taken to make the functionality as comprehensive and reliable as possible there will undoubtedly be edge cases that have been missed (or future browsers) that are incorrectly validated. As such it is recommended to treat responses as advisory only.
Credits
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.