ablota/laravel-threema-notification-channel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. 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"
				}
			}
		}
	]
}
  1. Install the package with Composer:
composer require ablota/laravel-threema-notification-channel
  1. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 ablota/laravel-threema-notification-channel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-03-05