Files
gsf/app/Console/Commands/PushNotification.php
vedant-chavan 20f55281ef save to codehub
2024-08-09 17:11:41 +05:30

65 lines
1.8 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\NotificationUser;
use Ladumor\OneSignal\OneSignal;
class PushNotification extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'send:notification_daily';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send Notification Daily';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$title = "";
$messages = [
"Open the GSF App and Start Counting Every Step Towards a Fitter You!",
"Every step counts on a fitness journey. Open GSF to track yours!",
"Open GSF and log your steps to see how you rank on the leaderboard.",
"The competition is heating up! Open GSF to track your steps and stay ahead.",
"Get moving and conquer your fitness goals! Open GSF to track your steps."
];
$random = array_rand($messages);
$message = $messages[$random];
// $playerId = "092051ad-e7f3-47c1-b8cf-55db5a4232c3";
$fields = [
// 'include_player_ids' => [$playerId],
'included_segments'=>[ 'All'],
'contents' => ['en' => $message],
'headings' => ['en' => $title],
'isAndroid'=> true,
'content_available' => true,
// 'data' => [
// 'content_type' => $content_type,
// 'id' => $id,
// ],
// 'big_picture' => $imageUrl,
// 'app_id' => env('ONE_SIGNAL_APP_ID'),
// 'authorization' => env('ONE_SIGNAL_AUTHORIZE')
];
$result = OneSignal::sendPush($fields);
}
}