lakshanjs / simple-apns-notifications
一个简单而强大的PHP类,用于发送APNs通知。
v1.0
2024-07-27 16:02 UTC
Requires
- php: >=7.4
README
一个简单而强大的PHP类,用于发送APNs通知。
安装
您可以通过Composer安装此包
composer require lakshanjs/simple-apns-notifications
用法
require 'vendor/autoload.php'; use SimpleAPNsNotifications\APNsNotification; $keyId = 'YOUR_KEY_ID'; // Your Key ID $teamId = 'YOUR_TEAM_ID'; // Your Team ID $bundleId = 'com.example.yourapp'; // Your Bundle ID $privateKeyPath = 'path/to/AuthKey_YOUR_KEY_ID.p8'; // Path to your .p8 file $deviceToken = 'YOUR_DEVICE_TOKEN'; // Device Token $notification = new APNsNotification($keyId, $teamId, $bundleId, $privateKeyPath); $notification->setDeviceToken($deviceToken); $notification->setAlert('Incoming Call', 'You have an incoming call'); $notification->setCustomValue('customKey', 'customValue'); $notification->setPushType('voip'); // Set the push type to 'voip' for VoIP notifications $notification->setProduction(false); // Set to true for production environment $notification->setPriority(10); // Set the priority (10 for high, 5 for low) $notification->setExpiration(time() + 3600); // Set the expiration time to 1 hour from now $notification->setCollapseId('collapse-id'); // Set the collapse ID list($httpcode, $response) = $notification->send(); if ($httpcode == 200) { echo "Notification sent successfully!\n"; } else { echo "Error sending notification: HTTP $httpcode\n"; echo "Response: $response\n"; }
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。