Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Laravel support #46

Closed
wants to merge 2 commits into from

Conversation

shaffe-fr
Copy link

Hi,
Following issue #42, this PR allows an optionnal and simple Laravel support.

It offers a out of the box Laravel compatibility, you'll just have to add the following variables to your .env file:

FCM_API_KEY=
FCM_SENDER_ID=

You can use the facade:

use Fcm\Laravel\Fcm;
use Fcm\Push\Notification;

Fcm::send(
  (new Notification())
    ->setTitle('My title')
    ->setBody('My body')
    ->setClickAction('OPEN_ACTIVITY_1')
    ->addData('url', url())
    ->addRecipient('my-device-token')
);

You can also use the dependencies injection (controllers, jobs, app(FcmClient::class) helper...):

use Fcm\FcmClient;
use Fcm\Push\Notification;

class MyClass
{
    public function myMethodWithDependenciesInjection(FcmClient $client)
    {
        $client->send(
          (new Notification())
            ->setTitle('My title')
            ->setBody('My body')
            ->setClickAction('OPEN_ACTIVITY_1')
            ->addData('url', url())
            ->addTopic('my-topic')
        );
    }
}

As it's optionnal, I chose to put everything related to Laravel in a subfolder, even the config file.
There are no documentations yet.

Thanks

@coveralls
Copy link

Pull Request Test Coverage Report for Build 816

  • 1 of 19 (5.26%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-8.3%) to 90.654%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/FcmClient.php 1 2 50.0%
src/Laravel/Fcm.php 0 1 0.0%
src/Laravel/stubs/config.php 0 2 0.0%
src/Laravel/FcmServiceProvider.php 0 14 0.0%
Totals Coverage Status
Change from base Build 813: -8.3%
Covered Lines: 194
Relevant Lines: 214

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jan 20, 2021

Pull Request Test Coverage Report for Build 817

  • 1 of 19 (5.26%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-8.3%) to 90.654%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/FcmClient.php 1 2 50.0%
src/Laravel/Fcm.php 0 1 0.0%
src/Laravel/stubs/config.php 0 2 0.0%
src/Laravel/FcmServiceProvider.php 0 14 0.0%
Totals Coverage Status
Change from base Build 813: -8.3%
Covered Lines: 194
Relevant Lines: 214

💛 - Coveralls

@AndyGaskell
Copy link
Collaborator

Hi @shaffe-fr
Sorry, I've not had a chance to come back to this. It just needs a bit more in terms of unit tests.

@shaffe-fr
Copy link
Author

Hi @AndyGaskell,
I'm not sure how to add unit tests without bringing the whole laravel package. Do you have any idea?
Thanks

rolinger added a commit that referenced this pull request Sep 7, 2024
Had to clean up changes that came from #46 that were merged after this #59 was created.
@rolinger
Copy link
Collaborator

rolinger commented Sep 7, 2024

The master has been updated with all other PRs except this one. Because we need additional tests AND the other merges were newer than this one I ask that you update this lavarel PR to include proper tests and ensure your changes are still in line with all the other PRs (that were newer) that have now been merged.

@rolinger rolinger closed this Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants