定制 zandor300/apnsframework 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

zandor300/apnsframework

最新稳定版本:1.6.4

Composer 安装命令:

composer require zandor300/apnsframework

包简介

PHP framework for easy interaction with Apple's Push Notification Service.

README 文档

README

Build Version License PHP Version Downloads

PHP framework for easy interaction with the Apple Push Notification Service.

Install

You can use composer to include this framework into your project. The project is available through Packagist.

composer require zandor300/apnsframework

Dependencies

This framework depends on the firebase/php-jwt package.

Usage

Creating APNS object.

use APNSFramework;

$teamId = "";
$bundleId = "";
$authKeyPath = "";
$authKeyId = "";

try {
    $apns = new APNS($teamId, $bundleId, $authKeyPath, $authKeyId);
} catch (APNSException $e) {
    echo "Error: " . $e->getMessage();
    // Handle exception
}

Creating a basic notification

$notification = new APNSNotification();

$notification->setTitle("Example Notification");
$notification->setBody("This is an example notification!");

$notification->setBadge(2);

Creating a token object

try {
    $tokenString = "<FILL IN THE APNS TOKEN>";

    $environment = APNSTokenEnvironment::development;
    //$environment = APNSTokenEnvironment::production;

    $token = new APNSToken($tokenString, $environment);
} catch (APNSException $e) {
    echo "Error: " . $e->getMessage();
    // Handle exception
}

Sending the notification

try {
    $apns->sendNotification($notification, $token);
} catch (APNSDeviceTokenInactive $e) {
    // Remove device token from database since it's inactive.
} catch (APNSException $e) {
    echo "Error: " . $e->getMessage();
    // Handle exception
}

Troubleshooting

Certificate errors

You might need to set the root certificate for the APNS request using setRootCertificatePath on the APNS object. You can download this certificate using the link in the Apple Developer documentation: Establish a Trusted Connection to APNs > AAA Certificate Services root certificate

$apns->setRootCertificatePath(__DIR__ . "/AAACertificateServices.crt");

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-04-25