quickcamx/devices
Composer 安装命令:
composer require quickcamx/devices
包简介
Manage mobile devices and tokens easily with Laravel
README 文档
README
Manage mobile devices and tokens easily with Laravel
Easily manage devices and device tokens for your users.
Installation
You can install the package via composer:
composer require sfolador/devices
You can publish the config file with:
php artisan vendor:publish --tag="devices-config"
This is the contents of the published config file:
return [ 'allow_device_reassign' => false, ];
if you set allow_device_reassign to true, it will be possible to
register a device for a user and then assign it to another user. This happens usually
in mobile applications with multi-accounts on the same device.
You can publish and run the migrations with:
php artisan vendor:publish --tag="devices-migrations"
php artisan migrate
the migration will create the Devices table and its columns will be:
id- the device idnotifiable_id- the "user" idnotifiable_type- the "user" typename- the device nametype- the device type (mobile, web)platform- the device platform (ios, android, web)token- the device tokencreated_at- the device creation dateupdated_at- the device update date
Usage
It's possible to use the HasDevices trait in your User model:
use Sfolador\Devices\Models\Concerns\HasDevices; class User extends Authenticatable { use HasDevices; }
At this point is possible to retrieve the devices of a user:
$user = User::find(1); $user->devices;
To register a new Device, for example from a mobile app, you can use the provided route POST /api/devices/attach:
Route::post('/devices/attach', [DeviceController::class, 'attach']);
Device parameters
The register a Device you need a request with these parameters:
$rules = [ 'platform' => ['required', new Enum(DevicePlatform::class)], 'type' => ['required', new Enum(DeviceType::class)], 'token' => 'required|string', ];
DevicePlatform is an Enum that can have these values: android, ios, web. DeviceType is an Enum that can have these values: mobile, web
Firebase notifications
If needed, this package can send push notifications with Firebase through the use of : kutia-software-company/larafirebase (https://github.com/kutia-software-company/larafirebase) ,
already present in the composer.json.
You need to publish the configuration of kutia-software-company/larafirebase by launching:
php artisan vendor:publish --provider="Kutia\Larafirebase\Providers\LarafirebaseServiceProvider"
you will find the larafirebase.php file in the config folder. The file looks like this:
return [ 'authentication_key' => null ];
Please remind that you need to obtain the authentication_key from Firebase
Notifiable configuration
You need to setup your notifiable class by adding the RouteNotifications trait:
class User extends Model { use HasDevices; use RoutesNotifications; ...
You are now ready to send a notification to the user:
$user = User::find(1); $user->notify(new \Sfolador\Devices\Notifications\FirebasePushNotification('title','message'));
If you need more freedom on the notification fields you can always create another PushNotification class or extend
\Sfolador\Devices\Notifications\FirebasePushNotification.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
quickcamx/devices 适用场景与选型建议
quickcamx/devices 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Devices」 「sfolador」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 quickcamx/devices 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quickcamx/devices 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 quickcamx/devices 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
A collection of unit conversions utils for Laravel
Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
This package helps user to fix typos in email addresses by using openai api to suggest a valid email address.
Manage mobile devices and tokens easily with Laravel
Agent is a PHP/Laravel package for detecting devices/bots via the http request.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-08