PHP code example of kingscode / laravel-apns-notification-channel

1. Go to this page and download the library: Download kingscode/laravel-apns-notification-channel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kingscode / laravel-apns-notification-channel example snippets


'connections' => [
    'apn' => [
        'key_id'               => env('APN_KEY_ID'),
        'team_id'              => env('APN_TEAM_ID'),
        'app_bundle'           => env('APN_APP_BUNDLE'),
        'private_key'          => storage_path('apn.p8'),
        'private_key_password' => env('APN_KEY_PASSWORD', null),
        'is_production'        => env('APN_PRODUCTION', false),
    ],
];

public function routeNotificationForApn(): string
{
    return $this->apn_token;
}

/**
 * Get the notification in APN format.
 *
 * @param $notifiable
 * @return \KingsCode\LaravelApnsNotificationChannel\Message
 */
public function toApn($notifiable): Message
{
    return (new Message())
        ->setTitle('title')
        ->setBody('body');
}

public function via($notifiable): array
{
    return [ApnChannel::class];
}