ablota/laravel-threema-notification-channel
Composer 安装命令:
composer require ablota/laravel-threema-notification-channel
包简介
Laravel package for sending notifications with Threema.
README 文档
README
Laravel package for sending notifications with Threema.
Prerequisites
- Add the following repository to your
composer.json:
{
"repositories": [
{
"type": "package",
"package": {
"name": "threema/msgapi-sdk",
"version": "1.5.6",
"dist": {
"url": "https://gateway.threema.ch/sdk/threema-msgapi-sdk-php-1.5.6.zip",
"type": "zip"
}
}
}
]
}
- Install the package with Composer:
composer require ablota/laravel-threema-notification-channel
- Request a Threema Gateway ID. Register to get a basic ID for testing immediately. If you are interested in an end-to-end ID, contact Threema and they will usually provide you with an ID for testing.
Configuration
The package includes a configuration file. However, you are not required to export this configuration file to your own application. You can simply use the environment variables below:
// Required
THREEMA_GATEWAY_ID=
THREEMA_GATEWAY_SECRET=
// Optional
THREEMA_GATEWAY_PRIVATE_KEY=
THREEMA_MSGAPI_HOST=
THREEMA_TLS_FORCE_HTTPS=true|false
THREEMA_TLS_CIPHER=...
THREEMA_TLS_VERSION=1.0|1.1|1.2
The required variables are shown on the Threema Gateway website. The THREEMA_GATEWAY_PRIVATE_KEY is required in
hex if you're using the end-to-end mode.
Formatting Notifications
If a notification supports being sent as a Threema message, you should define a toThreema method on the notification class. This method will receive
a $notifiable entity and should return an Illuminate\Notifications\Messages\ThreemaMessage instance. Let's take a look at a basic toThreema
example:
use Illuminate\Notifications\Messages\ThreemaMessage;
use Illuminate\Notifications\Messages\ThreemaTextMessage;
public function toThreema(mixed $notifiable): ThreemaMessage
{
return new ThreemaTextMessage('Hello World!');
}
Right now only 1:1 chat messages (text, image, location, audio, video, file) are supported. Group message types are coming soon.
Routing Notifications
To route Threema notifications to the proper Threema ID, define a routeNotificationForThreema method on your notifiable entity:
use Threema\MsgApi\Receiver;
public function routeNotificationForThreema(mixed $notification): Receiver
{
return new Receiver($this->threema_id, Receiver::TYPE_ID);
}
By using Receiver::TYPE_EMAIL or Receiver::TYPE_PHONE you can make use of an automatic ID lookup.
Exceptions
The package only throws the following exceptions:
ThreemaChannelException
Is thrown in case of fatal errors. For example, if certain types are not supported or the configuration is incorrect.
ThreemaChannelResultException
Since Laravel does not return a result when sending notifications, this exception is thrown instead. For example, sending a message to an unknown Threema ID would lead into this exception. It should be caught and the result it contains should be processed:
use Illuminate\Notifications\Exceptions\ThreemaChannelResultException;
try {
$notifiable->notify(new TwoFactorVerificationCode());
} catch(ThreemaChannelResultException $exception) {
$exception->getResult();
}
ablota/laravel-threema-notification-channel 适用场景与选型建议
ablota/laravel-threema-notification-channel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notification」 「laravel」 「channel」 「Threema」 「ablota」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ablota/laravel-threema-notification-channel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ablota/laravel-threema-notification-channel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ablota/laravel-threema-notification-channel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
Send SMS and SMS Notification via Mailjet for Laravel
Extensible library for building notifications and sending them via different delivery channels.
The package enables developers to send request to discord webhook in order to create message and send it discord channel.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-05