Comments (9)
It could be that you haven't done the php artisan vendor:publish before the registration of the serviceprovider (LaravelFCM\FCMServiceProvider::class ) in the app.php file.
please try again php artisan vendor:publish with LaravelFCM\FCMServiceProvider::class
registered in your config/app-php
file.
Please give me a feedback if it's working or not
PS: Please check if in config folder you have a fcm.php file.
Best regards
from laravel-fcm.
Hello have you done an artisan publish command ?
from laravel-fcm.
Hi,
Yep, I had made the "php artisan vendor:publish".
To be honest, I rechecked twice all the commands that were wrote in the readme.md
I even tried to understand the problem, that appears to be because the variable $app is undefined. But I cannot understand from where this is coming from.
sorry, I'm new to laravel, but I already installed few packages and didn't have this issue before.
Can I check any file to verify if I installed it correctly?
Thanks,
Joao
from laravel-fcm.
Sorry, but didn't work (Same error):
here is the result of the vendor:publish command:
D:\>php artisan vendor:publish
Copied Directory [\vendor\laravel\framework\src\Illuminate\Notifications\resources\views] To [\resources\views\vendor\notifications]
Copied Directory [\vendor\laravel\framework\src\Illuminate\Pagination\resources\views] To [\resources\views\vendor\pagination]
Copied Directory [\vendor\laravel\passport\resources\views] To [\resources\views\vendor\passport]
Copied Directory [\vendor\laravel\passport\resources\assets\js\components] To [\resources\assets\js\components\passport]
Copied Directory [\vendor\laravel\framework\src\Illuminate\Mail\resources\views] To [\resources\views\vendor\mail]
Publishing complete.
I can also confirm that the fcm.php file is in the config folder(I added the SERVER_KEY and SENDER_ID in the .env file):
return [
'driver' => env('FCM_PROTOCOL', 'http'),
'log_enabled' => true,
'http' => [
'server_key' => env('FCM_SERVER_KEY', 'Your FCM server key'),
'sender_id' => env('FCM_SENDER_ID', 'Your sender id'),
'server_send_url' => 'https://fcm.googleapis.com/fcm/send',
'server_group_url' => 'https://android.googleapis.com/gcm/notification',
'timeout' => 30.0, // in second
],
];
I did add the serviceprovider in the app.php file (Before calling the vendor:publish):
....
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class,
Laravel\Passport\PassportServiceProvider::class,
/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
LaravelFCM\FCMServiceProvider::class,
],
and also:
....
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'FCM' => LaravelFCM\Facades\FCM::class,
'FCMGroup' => LaravelFCM\Facades\FCMGroup::class, // Optional
],
Finally, the ONLY thing that I thought that was weird is that my bootstrap\app.php file doesn't contain anything similar of what the LUMEN part was saying. I actually never opened this file before. But I still added the lines to this file. Then, I did notice that the aliases didn't work in my code, but I just added the full path to get it running (Still crashing, but not complaining that the FCM was not found).
My bootstrap\app.php
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/
$app->singleton(
Illuminate\Contracts\Http\Kernel::class,
App\Http\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Console\Kernel::class,
App\Console\Kernel::class
);
$app->singleton(
Illuminate\Contracts\Debug\ExceptionHandler::class,
App\Exceptions\Handler::class
);
$app->register(LaravelFCM\FCMServiceProvider::class);
class_alias(\LaravelFCM\Facades\FCM::class, 'FCM');
class_alias(\LaravelFCM\Facades\FCMGroup::class, 'FCMGroup');
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
And, in my file, I'm using:
use LaravelFCM\Facades\FCM;
use LaravelFCM\Message\OptionsBuilder;
use LaravelFCM\Message\PayloadDataBuilder;
use LaravelFCM\Message\PayloadNotificationBuilder;
and this is the entire method:
public static function sendMessageToToken($users, $message) {
$tokens = [];
foreach ($users as $user) {
foreach ($user->fcmTokens as $token)
$tokens[] = $token;
}
$tokens[] = "dFQwbIxI3J0:APA91bFzXpm4atxAYvZLfZsx78kCI711";
$optionBuiler = new OptionsBuilder();
$optionBuiler->setTimeToLive(60*20);
$notificationBuilder = new PayloadNotificationBuilder('AgendaF1');
$notificationBuilder->setBody($message)->setSound('default');
$dataBuilder = new PayloadDataBuilder();
$dataBuilder->addData(['a_data' => 'my_data']);
$option = $optionBuiler->build();
$notification = $notificationBuilder->build();
$data = $dataBuilder->build();
$downstreamResponse = FCM::sendTo($tokens, $option, $notification, $data);
return $downstreamResponse->numberSuccess();
// $downstreamResponse->numberFailure();
// $downstreamResponse->numberModification();
//
////return Array - you must remove all this tokens in your database
// $downstreamResponse->tokensToDelete();
//
////return Array (key : oldToken, value : new token - you must change the token in your database )
// $downstreamResponse->tokensToModify();
}
I believe that this is all the files that I changed. Any idea what is wrong? How can I force a republish, just to be sure?
from laravel-fcm.
It's strange. It's look like a issue with the config file.
Can you try to remove all files and the package in vendor/brozot/
then reinstall it with composer, remove also the config/fcm.php
make a vendor:publish command.
you can also remove the content added in your boostrap/app.php
you need to add this line only if you use Lumen.
Thank you
from laravel-fcm.
Just tried what you said.
Got the same error.
Could be related to the laravel version? I'm using the: Laravel Framework 5.4.19
from laravel-fcm.
I have tried also with Laravel 5.4.19 and it works for me.
I have release a new version 1.2.4.
In this version the command vendor:publish is optional.
Can you try to update the package
thank you
from laravel-fcm.
Hey,
Thanks for the changes, apparently this fixed the initial issue.
Now I'm getting a new one:
RequestException in CurlFactory.php line 187:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
in CurlFactory.php line 187
at CurlFactory::createRejection(object(EasyHandle), array('errno' => 60, 'error' => 'SSL certificate problem: unable to get local issuer certificate', 'url' => 'https://fcm.googleapis.com/fcm/send', 'content_type' => null, 'http_code' => 0, 'header_size' => 0, 'request_size' => 0, 'filetime' => -1, 'ssl_verify_result' => 20, 'redirect_count' => 0, 'total_time' => 0.188, 'namelookup_time' => 0.063, 'connect_time' => 0.078, 'pretransfer_time' => 0, 'size_upload' => 0, 'size_download' => 0, 'speed_download' => 0, 'speed_upload' => 0, 'download_content_length' => -1, 'upload_content_length' => -1, 'starttransfer_time' => 0, 'redirect_time' => 0, 'redirect_url' => '', 'primary_ip' => '216.58.202.10', 'certinfo' => array(), 'primary_port' => 443, 'local_ip' => '192.168.25.8', 'local_port' => 58176)) in CurlFactory.php line 150
at CurlFactory::finishError(object(CurlHandler), object(EasyHandle), object(CurlFactory)) in CurlFactory.php line 103
at CurlFactory::finish(object(CurlHandler), object(EasyHandle), object(CurlFactory)) in CurlHandler.php line 43
at CurlHandler->__invoke(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Proxy.php line 28
at Proxy::GuzzleHttp\Handler\{closure}(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Proxy.php line 51
at Proxy::GuzzleHttp\Handler\{closure}(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in PrepareBodyMiddleware.php line 72
at PrepareBodyMiddleware->__invoke(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Middleware.php line 30
at Middleware::GuzzleHttp\{closure}(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' =>
I will investigate this error as well. If I found something I will let you know.
from laravel-fcm.
Hey,
Great news!!!! It worked!
I found the solution for the last problem here(I'm using a localhost php and mysql installations):
link here
I will copy here the solution (It was not me that wrote it, it's the person in the link above):
Go to http://curl.haxx.se/ca/cacert.pem and download the pem file and save in your php installation directory ( make sure while saving it retains the extension and not saved as a text file )
Now, open your php.ini file, scroll to the bottom and add the following line:
[cURL]
curl.cainfo="D:\xampp\php\cacert.pem"
Replace D:\xampp\php\cacert.pem with the actual path.Courtesy: http://stackoverflow.com/questions/17478283/paypal-access-ssl-certificate-unable-to-get-local-issuer-certificate
from laravel-fcm.
Related Issues (20)
- Notification sound not working HOT 3
- Support guzzle 7.0
- send notification issue
- Change the connection on the fly
- SnederId Mismatch
- Lumen - Unable to resolve NULL driver for [LaravelFCM\FCMManager]. HOT 1
- onMessage payload not working HOT 1
- Laravel 8 HOT 6
- How to add badge on push notification using brozot/Laravel-FCM
- How to test FCM::sendTo with Feature test HOT 4
- Laravel 8 supported or not?(php 8) HOT 6
- How to send FCMGroup?
- Find exact error code or error message in responce
- How to add small icon on the right side of the notification.
- Not working on iOS devices HOT 2
- Your requirements could not be resolved to an installable set of packages. HOT 4
- Not compatible with guzzle ~7.0 HOT 1
- Not support in Laravel 9 HOT 1
- Not Support In Laravel 10 HOT 1
- Is this package abandoned?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-fcm.