<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Kreait\Firebase\Factory;
use Kreait\Firebase\Contract\Messaging;

class FirebaseServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton(Messaging::class, function ($app) {
            $firebaseConfigPath = storage_path('/bayea3-firebase-adminsdk.json');

            $factory = (new Factory)
                ->withServiceAccount($firebaseConfigPath);

            return $factory->createMessaging();
        });
    }
}
