1. Go to this page and download the library: Download maatify/google-fcm 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/ */
maatify / google-fcm example snippets
use Maatify\FCM\FcmHandler;
_credentials_json_file_location__);
try {
// $message->sender cannot callable before setting at least one of optional setter
$result = $message->sender->ToDeviceToken(__device_token__);
} catch (MessagingException|FirebaseException $e) {
$result = (array) $e;
}
print_r($result);
// $message->sender cannot callable before setting at least one of optional setter
$result = $message->sender->ToMultipleDevicesToken([__device_token1__, __device_token2__]);
print_r($result);
try {
// $message->sender cannot callable before setting at least one of optional setter
$result = $message->sender->ToTopic(__topic__);
} catch (MessagingException|FirebaseException $e) {
$result = (array) $e;
}
print_r($result);
try {
$tokens = [__device_token__]; // to validate one token only
$result = $message->TopicValidation()->ValidateRegistrationTokens($tokens);
} catch (MessagingException|FirebaseException $e) {
$result = (array) $e;
}
print_r($result);