Git Product home page Git Product logo

laravel-fcm's People

Contributors

alvsconcelos avatar anich avatar appkr avatar arubacao avatar brozot avatar chimit avatar codehimanshu avatar darius-sv avatar enniel avatar fawzanm avatar gaffel avatar gcphost avatar hsharghi avatar jacovdbosch avatar luiztessadri avatar marfurt avatar rasmuscnielsen avatar slpixe avatar vigneshgurusamy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-fcm's Issues

Consuming too much memory and CPU resources when sending push to large number of users

I am trying to send push notifications in bulk. Now I've 400 devices registered on my live server. When we are sending a push notification to all of them our memory and CPU usage rises drastically thus slowing down our system. When I check with the server logs 400-500 new processes are being generated when push notification is triggered. I am using the same code from package readme example i.e
`$tokens = array of push tokens;
$downstreamResponse = FCM::sendTo($tokens, $option, $notification, $additionalData);

if ($downstreamResponse->tokensToDelete()) {
Device::whereIn('device_push_token',$downstreamResponse->tokensToDelete())->delete();
}
`
Is there anything I am doing wrong? Or there are any limitations from FCM/this package? Or should I try any alternate method like groups, topics?

Use multiple sender id for multiple apps using brozot

I have multiple mobile apps (for each app I manage different server key and sender id) and I am using same laravel backend to send notifications to all different mobile apps.
How can I send notification to different app using different sender id (not using single sender id) with laravel brozot package?

crashing after fresh install

Hi,

I had followed the step by step explanation, but I'm getting an error when trying to send a message.

ErrorException in Manager.php line 77:
Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in D:\vendor\laravel\framework\src\Illuminate\Support\Manager.php on line 88 and defined
in Manager.php line 77
at HandleExceptions->handleError(2, 'Missing argument 1 for Illuminate\\Support\\Manager::createDriver(), called in D:\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Manager.php on line 88 and defined', 'D:\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Manager.php', 77, array('this' => object(FCMManager))) in Manager.php line 77
at Manager->createDriver() in Manager.php line 88
at Manager->createDriver(null) in Manager.php line 63
at Manager->driver() in FCMServiceProvider.php line 27
at FCMServiceProvider->LaravelFCM\{closure}(object(Application), array()) in Container.php line 716
at Container->build(object(Closure)) in Container.php line 598
at Container->resolve('fcm.client') in Container.php line 567
at Container->make('fcm.client') in Application.php line 708
at Application->make('fcm.client') in Container.php line 1139
at Container->offsetGet('fcm.client') in FCMServiceProvider.php line 38
at FCMServiceProvider->LaravelFCM\{closure}(object(Application), array()) in Container.php line 716
at Container->build(object(Closure)) in Container.php line 598
at Container->resolve('fcm.sender') in Container.php line 567
at Container->make('fcm.sender') in Application.php line 708
at Application->make('fcm.sender') in Container.php line 1139
at Container->offsetGet('fcm.sender') in Facade.php line 159
at Facade::resolveFacadeInstance('fcm.sender') in Facade.php line 128
at Facade::getFacadeRoot() in Facade.php line 215
at Facade::__callStatic('sendTo', array(array('dFQwbIxI3J0:APA91bFzXpm4atxUHhtAYvZLfZsx78kCI711'), object(Options), object(PayloadNotification), object(PayloadData))) in ApiController.php line 190
at FCM::sendTo(array('dFQwbIxI3J0:Ch6HGrkAqe6p0ra969kjBa_HzdqAsgfi67EMbLI711'), object(Options), object(PayloadNotification), object(PayloadData)) in ApiController.php line 190
at ApiController::sendMessageToToken(object(Collection), 'Testing') in ApiController.php line 166
at ApiController->alertTeacherForDelay('15')
at call_user_func_array(array(object(ApiController), 'alertTeacherForDelay'), array('min' => '15')) in Controller.php line 55
at Controller->callAction('alertTeacherForDelay', array('min' => '15')) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(ApiController), 'alertTeacherForDelay') in Route.php line 204
at Route->runController() in Route.php line 160

Any idea what I'm doing wrong? Or is this a real bug?

PS: I already cleaned the cache in all the possible ways that I found in the internet and still no luck.

Thanks,
Joao

Ios not receiving notifications

Working fine with android, but doesn't work with ios. Tried set priority to high and content_available to true. No effect. In the same time, it works fine when I'm sending notification via firebase console or curl (both from php or linux console). Can you help me? Is it bug or I'm doing smth wrong? I tried the example from documentation (downstream Messages)

log_enabled is set to default

setting log_enabled to false is more production oriented and therefore one is not so much required to publish the config file

Does not install in Laravel 4

I tried to install Laravel-FCM but was unable to do so.

Here is what I did:

  1. I included "brozot/laravel-fcm": "^0.9.3" in the require array of composer.json but it refuses to install. It returns an error message which tells me that I need to update my guzzle to ~6.0.

cms

  1. I tried replacing my current guzzle to ~6.0 which in turn tells me that I need to update my laravel framework.

Is there a way or a work around to make it work in laravel 4.2.

TopicResponse issue

For multiple topics defined, in TopicResponse on line 102 there is array to string conversion error for $logMessage. The problem is in $topic, problem is solved using json encode on $topic. Can you check this?

Ios and android notification not sending

LaravelFCM\Response\DownstreamResponse Object
(
[numberTokensSuccess:protected] => 0
[numberTokensFailure:protected] => 1
[numberTokenModify:protected] => 0
[messageId:protected] =>
[tokensToDelete:protected] => Array
(
[0] => dppE1iQTuec:APA91bHHrKccNItw9ZHevSaw6MfVrNbvv_XI1XRcqSS2-n-8EKpLt9AwTJCk97UyyYZrrkl8jHTGiprmpDSRCDHZfY5gzX80oWV5x0Qlpci4sYMJaio8Qy8jG298-As8ogBmQ_x0FxEE
)

[tokensToModify:protected] => Array
    (
    )

[tokensToRetry:protected] => Array
    (
    )

[tokensWithError:protected] => Array
    (
    )

[hasMissingToken:protected] => 
[tokens:LaravelFCM\Response\DownstreamResponse:private] => Array
    (
        [0] => dppE1iQTuec:APA91bHHrKccNItw9ZHevSaw6MfVrNbvv_XI1XRcqSS2-n-8EKpLt9AwTJCk97UyyYZrrkl8jHTGiprmpDSRCDHZfY5gzX80oWV5x0Qlpci4sYMJaio8Qy8jG298-As8ogBmQ_x0FxEE
    )

[logEnabled:protected] => 1

)

Data & Icon not showing in the browser notification

I've followed the steps correctly but when I send browser push notification, neither shows data(title, body) correctly nor shows icon image. I'm not sure whether it is about this package or about FCM itself? Can someone help me in this?

Undefined Property $Failure in FCMGROUP::GroupResponse

Hi,
I am receiving this kind of new error, after updating composer

Undefined Property $Failure in FCMGROUP::GroupResponse
Seems like you didnt define the Failure variable or you would have changed any naming convention in GroupResponse class.

kindly check & update it

Thanks

Missing Namespace for Topics in documentation (minor)

Hey @brozot Great library, got some great use from it.

I just noticed that the namespace for Topics wasn't included in the documentation. Shouldn't be difficult to add use LaravelFCM\Message\Topics; to the "Topics Messages" section of the documentation to make it immediately obvious to users. I can open a PR if you'd like.

Thanks again 👍

How can I make phone vibrate when push is send

Push notification working fine but the phone which receives push notification does not vibrate. Vibration is on and I can see vibration with other apps. Is there any way we can send vibration command through this package.

Type error: Too few arguments to function Illuminate\\Support\\Manager::createDriver()

I installed the package in my laravel, and when I'm trying to send a push notification to my device using the exact same code in the readme, I get the following error:

Type error: Too few arguments to function Illuminate\\Support\\Manager::createDriver(), 0 passed in \/home\/pokemoti\/public_html\/api\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Manager.php on line 87 and exactly 1 expected

The line caused the error is:

$downstreamResponse = FCM::sendTo($token, $option, $notification, $data);

I couldn't figure out what's wrong as soon as it's the documentation code..

What's could have gone wrong?

When does tokensToModify get populated?

I've been implementing your package to send FCM notifications, which is working fine. Currently I'm implementing a case for tokensToModify.

By reinstalling my client-app, I am able to generate or refresh tokens. At this moment though the old token is still in my database.

So when sending to the old token, ( after refreshing tokens from the client ), I expect to see the old token as key with the new token as value in the tokensToModify() array. This never happens though. The old tokens will always be inserted in to the tokensToDelete array.

I might have misunderstood the tokensToModify method. But i would like some explanation on how to use this method on the server side.

Cant get it to work

Hello i am using your plugin but it does not send a push notificiation for me, is there something wrong with these lines of code?

$notificationBuilder = new PayloadNotificationBuilder('my title');
$notificationBuilder->setBody('body')
->setSound('default');

$notification = $notificationBuilder->build();

$optionBuilder = new OptionsBuilder();

$deviceResponse = FCM::sendTo($userKey, $optionBuilder->build(), $notification);

Missing argument 1

ErrorException in Manager.php line 77: Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in /var/www/html/API-DIR/events/vendor/illuminate/support/Manager.php on line 87 and defined

When i try to send notification i service above mentioned error. i am using lumen framework.

Here is my code :

`$optionBuiler = new OptionsBuilder();
$optionBuiler->setTimeToLive(60*20);

    $notificationBuilder = new PayloadNotificationBuilder('My test notification');
    $notificationBuilder->setBody('Hello world')
                         ->setSound('default');


    $dataBuilder = new PayloadDataBuilder();
    $dataBuilder->addData(['a_data' => 'my_data']);

    $option = $optionBuiler->build();
    $notification = $notificationBuilder->build();
    $data = $dataBuilder->build();

    $token = "token";

   $downstreamResponse = FCM::sendTo($token, $option, $notification, $data);`

Thanks

Mutliple Android Applications

How am I to integrate it for two different Android Applications using the same Laravel Application.

Both Andoid Application would have different Sender IDs.

Subscribe/Unsubscribe Topic for User ?

Hi,
how i can achieve subscribe and unsubscribe topic from user token with this library ?
I saw others php library fcm can do it like e.x https://github.com/sngrl/php-firebase-cloud-messaging

#Subscribe user to the topic

use sngrl\PhpFirebaseCloudMessaging\Client;

$server_key = '_YOUR_SERVER_KEY_';
$client = new Client();
$client->setApiKey($server_key);
$client->injectGuzzleHttpClient(new \GuzzleHttp\Client());

$response = $client->addTopicSubscription('_SOME_TOPIC_ID_', ['_FIRST_TOKEN_', '_SECOND_TOKEN_']);
var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

#Remove user subscription to the topic

use sngrl\PhpFirebaseCloudMessaging\Client;

$server_key = '_YOUR_SERVER_KEY_';
$client = new Client();
$client->setApiKey($server_key);
$client->injectGuzzleHttpClient(new \GuzzleHttp\Client());

$response = $client->removeTopicSubscription('_SOME_TOPIC_ID_', ['_FIRST_TOKEN_', '_SECOND_TOKEN_']);
var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

DownstreamResponse messageId property is not set and not logged.

In \LaravelFCM\Response\DownstreamResponse::parse() the messageId is not set, seems unfinished.
Right now it looks like this:

if (array_key_exists(self::MULTICAST_ID, $responseInJson)) {
    $this->messageId;
}

Also a getter is missing for messageId property and it is not logged at all in the logResponse method.
The messageId is really important for debugging, only reliable way to cross reference firebase statistics and logs with server logs.

On another note:
Logging is probably not ideally solved here by just instantiating a new StreamHandler. It's hardcoded and cannot be configured/adjusted. You should probably use Laravel's Log service.
Maybe something along the lines of:

Log::useDailyFiles(storage_path() . '/logs/laravel-fcm.log');
Log::info($logMessage);

chunk tokens?

hello. thankyou for amazing package.
Do I need tokens are sent be chunk of 999 ?

Is it possible add the notification buttons

Hello,
first of all congratulations for the excellent work and thanks for share!
I would like ask you (as title says) if it is possible add buttons on notification, for example like "whatsapp" that show if you want reply to message or close notification.

thank you!!

How set action on Closed App

Hello,
I would like to ask if I can set equivalent of .addAction() and .setStyle() of notification or how use app notification builder on closed app.
Because my problem is that when my app is closed does not execute code in onMessageReceived and I can't notification.setStyle or .addAction().

thank you for share!

Having issue with ios.

Working fine on android. Ios is receiving push through firebase console but not through laravel.
Please somebody help.

Trouble with additional parameters

Hello! First of all, thank you very much for great lib! Im using it on laravel 5.1)
In testing i have a same problem.

        $optionBuilder = new OptionsBuilder();
        $optionBuilder->setTimeToLive(30);

        $notificationBuilder = new PayloadNotificationBuilder('Auth');
        $notificationBuilder->setBody('Auth request...')
            ->setSound('default');

        $dataBuilder = new PayloadDataBuilder();
        $dataBuilder->addData(['a_data'=>[
            'mode'=>'auth',
            'private_key'=>'12345678901234567890123456789012'
        ]
]);

        $option = $optionBuilder->build();
        $notification = $notificationBuilder->build();
        $data = $dataBuilder->build();

        $token = '...';

        $downstreamResponse = FCM::sendTo($token, $option, $notification, $data);

and on Android i receive:

{a_data={“mode”:“auth”,“private_key”:“MXaFORX1dKZpXMCaiLl5uNo74yOqOTJW”}}

thats Ok! I can use a_data as json/object...

BUT on iOS i have a problem!

Push notification received: {
    “a_data” = “{\“mode\“:\“auth\“,\“private_key\“:\“TpbgLUn1Zq6WwREJxy3yGvgjEeaun75z\“}”;
    aps =     {
        alert =         {
            body = “Auth request...“;
            title = Auth;
        };
        sound = default;
    };
    “gcm.message_id” = “0:1496937050152314%939d13c6939d13c6";
}

a_data variable have string type, i can not use it.

Can you explain, how can i use sub-array in $dataBuilder->addData for iOS json/object type?

Undefined variable: response

what is the variable response passed to "new DownstreamResponse" under Downstream Messages example. I am getting an error with this.

Class fcm.sender does not exist

when i call:
$downstreamResponse = FCM::sendTo($this->tokens, $this->options, $this->notification,$this->data);

can someone help?

fcm.php is not generated

When I install the package and run the command php artisan vendor:publish, fcm.php is expected to be found in config directory , but it's not found. any idea about why this issue happens ?

How get my id´s token devices

Hello, i´m newer and hi have a question:
How can i get my tokens id´s phone ? ( $tokens = MYDATABASE::pluck('fcm_token')->toArray(); )
Thanks very much.

Incompatibility with Service Worker

HI, been using your library to send notifications to apps for a while, now Im implementing a js client with a service worker.

As referenced in this issue from firebaseJs firebase/quickstart-js#71

When sending in a notification the field notification this takes over and the custom handler does not trigger

Theres a way to call the notification field sent to firebase something else, or even skip it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.