davibennun / laravel-push-notification Goto Github PK
View Code? Open in Web Editor NEWLaravel package to enable sending push notifications to devices
Laravel package to enable sending push notifications to devices
Everything is working fine on my localhost but when uploaded to my server I'm getting -
Unable to connect to android.googleapis.com:443 . Error #0: stream_socket_client(): unable to connect to android.googleapis.com:443 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
I am using this code for GCM and it works well. Thank you for your code.
But, how can I use it's return value?
I can see the return value using print_r, but I don't know how to get it's response array.
Please tell me it's usage. thank you.
Does the package also support the Safari Push notifications?
https://developer.apple.com/notifications/safari-push-notifications/
I'm unsure if Apple have a uniform api for both OSX and iOS yet.
APNS first device work when multiple device per call.
others not working.
each device call work find.
Hello!
I am receiving this error only in Android (iOS is working well).
'Zend\Http\Client\Adapter\Exception\RuntimeException' with message 'Unable to enable crypto on TCP connection android.googleapis.com: make sure the "sslcafile" or "sslcapath" option are properly set for the environment.' in /home/casper/development/vendor/zendframework/zend-http/Zend/Http/Client/Adapter/Socket.php:310
Do you know how to solve it? I've been googling a little bit but I haven't found a proper solution.
Thank you very much! :D
I am trying to set keys like "collapseKey" and "delayWhileIdle" in GCM . I have no idea how to set those keys . This is how I set keys .
$message = PushNotification::Message($msg,array(
'msgcnt'=> 1,
'title'=>$event->title,
'collapseKey' => 'invited'
));
According to this collaposeKey is not working . And it is also inside payload of GCM instead .
any idea ? thanks
I need advice
How to store user device token?
ex.
When user on iphone login into app then I store his token?Keep that token hole time?
When user log out then remove or delete token?
What about when user decide to remove app? I will get response from apple so I can remove token?
Thanks
You could tag releases for separating Laravel 4 and 5 instead of pointing to dev-master which could be volatile.
I am trying to push notification with loc-key and loc-args with these lines of code.
$message = \PushNotification::Message("sentMsg",$detailForPush);
\PushNotification::app('myApp')->to($userDevice->deviceToken)->send($message);
and the $detailForPush are as follow:
detail for push : {"badge":1,"custom":{"custom data":{"itemId":"10","gid":"1"}},
"alert":{"lockey":"PUSH_MSG_FROM_GROUP","loc-args":["General","sentMsg"]}}
in my IOS Application, I set the "PUSH_MSG_FROM_GROUP" = "%@ : %@";
in my app's Localizable.strings
but when my IOS device receive push notification, i got this
push notification : {
aps = {
alert = sentMsg;
badge = 1;
sound = "bingbong.aiff";
};
"custom data" = {
gid = 1;
itemId = 10;
};
my alert key is overrided by the text. Any idea??
This doesn't work anymore
foreach ($regIds as $regId) {
$devices[] = Push::Device($regId);
}
// set adapter & send
$push = Push::app('gcmMain');
$push->adapter->setAdapterParameters(['sslverifypeer' => false]);
$collection = $push
->to(Push::DeviceCollection($devices))
->send(Push::Message($data['message'], $data));
foreach ($collection as $push) {
$response = $push->getAdapter()->getResponse();
}
I'm trying to sent push notification with special characters like "Á ó" or something like that and i dont receive the notification any idea? i trying to use ut8 encode and nothing..
Any ideas?
Thx
I think this package is a must have for those of us trying to cook Lumen APIs for mobile apps :)
Thank you for a great package!
Hi, May I know how can I send message to a subscribed topic ?
Thanks a lot
hi you, please suport windowphone8 :)
I am trying to install with Laravel 5 but i am facing installation error
I had some trouble installing the package, please specify within your readme that your package requires
"sly/notification-pusher": "dev-master"
to work probably otherwise good job done.
Hello,
My error is "Maximum execution time of 30 seconds exceeded" after push notification to iOS.
protected function read($length = 1024)
{
if (!$this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to reading data');
}
$data = false;
if (!feof($this->socket)) {
$data = fread($this->socket, (int) $length);//this line
}
I use Laravel4..
Hi,
I am newbie and using laravel 4 with this package. Want to know what is the "$deviceToken"
in the follwing code -
PushNotification::app('appNameIOS')
->to($deviceToken)
->send('Hello World, i`m a push message');
And how to get this $device token? PLease Help!
Could you update the "minimum-stability" to"stable" instead of "dev" ?
Due to a bug in PHP < 5.4 Cannot chain lookups/calls
You should update the PushNotification.php to this one to avoid this issue:
<?php namespace Davibennun\LaravelPushNotification;
class PushNotification {
public function app($appName)
{
return new App(\Config::get('laravel-push-notification::'.$appName));
}
public function Message()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\Message'));
return $instance->newInstanceArgs(func_get_args());
}
public function Device()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\Device'));
return $instance->newInstanceArgs(func_get_args());
}
public function DeviceCollection()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\Collection\DeviceCollection'));
return $instance->newInstanceArgs(func_get_args());
}
public function PushManager()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\PushManager'));
return $instance->newInstanceArgs(func_get_args());
}
public function ApnsAdapter()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\Adapter\ApnsAdapter'));
return $instance->newInstanceArgs(func_get_args());
}
public function GcmAdapter()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\GcmAdapter'));
return $instance->newInstanceArgs(func_get_args());
}
public function Push()
{
$instance = (new \ReflectionClass('Sly\NotificationPusher\Model\Push'));
return $instance->newInstanceArgs(func_get_args());
}
}
I'm having difficulty sending a push notification to an iOS device containing the key 'content-available' within the aps dictionary, as documented on Table 3-1 here.
Having dug around, it appears the origin of the issue is possibly within the ZendService\Apple\Apns\Message\Alert class.
I'm happy to create a PR for this fix but am looking for some guidance on whether this will need to be done within the Zend repo, or whether we can achieve it with this library?
I'm getting this error:
{
"exception": {
"type": "Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"code": 1,
"message": "Class 'Sly\\NotificationPusher\\Adapter\\' not found",
"file": "/var/www/reverse-api/vendor/davibennun/laravel-push-notification/src/Davibennun/LaravelPushNotification/App.php",
"line": 19,
"stackTrace": []
}
}
My composer.json:
{
"name": "plugapps/appname",
"description": "Description here",
"keywords": ["asdf", "asdf"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"predis/predis": "~1.0",
"aws/aws-sdk-php-laravel": "~2.0",
"barryvdh/laravel-ide-helper": "~2.0",
"barryvdh/laravel-cors": "0.5.x@dev",
"tymon/jwt-auth": "dev-laravel-5",
"davibennun/laravel-push-notification": "dev-laravel5"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"Reverse\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan ide-helper:generate",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan ide-helper:generate",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
Whats happen?
Hi,
I'm a new bee in laravel. Please, let me know how to install this in laravel 4.0 using composer. I tried the same way describe in readme and get following errors.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: remove laravel/framework 4.0.x-dev
- Conclusion: don't install laravel/framework 4.0.x-dev
- Conclusion: don't install laravel/framework v4.0.11
- Conclusion: don't install laravel/framework v4.0.10
- Conclusion: don't install laravel/framework v4.0.9
- Conclusion: don't install laravel/framework v4.0.8
- Conclusion: don't install laravel/framework v4.0.7
- Conclusion: don't install laravel/framework v4.0.6
- Conclusion: don't install laravel/framework v4.0.5
- Conclusion: don't install laravel/framework v4.0.4
- Conclusion: don't install laravel/framework v4.0.3
- Conclusion: don't install laravel/framework v4.0.2
- Conclusion: don't install laravel/framework v4.0.1
- Conclusion: don't install laravel/framework v4.0.0
- Installation request for davibennun/laravel-push-notification dev-master -> satisfiable by davibennun/laravel-push-notification[dev-master].
- Conclusion: don't install laravel/framework v4.0.0-BETA4
- Conclusion: don't install laravel/framework v4.0.0-BETA3
- davibennun/laravel-push-notification dev-master requires illuminate/support ~4.2 -> satisfiable by laravel/framework[4.2.x-dev], illuminate/support[4.2.x-dev, v4.2.0-BETA1, v4.2.1, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
- Can only install one of: laravel/framework[v4.0.0-BETA2, 4.2.x-dev].
- don't install illuminate/support 4.2.x-dev|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.0-BETA1|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.1|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.2|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.3|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.4|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.5|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.6|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.7|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.8|don't install laravel/framework v4.0.0-BETA2
- don't install illuminate/support v4.2.9|don't install laravel/framework v4.0.0-BETA2
- Installation request for laravel/framework 4.0.* -> satisfiable by laravel/framework[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.1, v4.0.10, v4.0.11, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9].
Thanks in advance.
E:\workspace\public_html\mobile>php artisan vendor:publish --provider="Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider" --tag="config"
Nothing to publish for tag [config].
*laravel 5.1
Hello, I'm using this library, everything in android goes fine in localhost and in my remote server. Also everything is fine in IOS but only in my localhost; in the remote server I only get the 500 error (after 30 seconds), I don't know what is going on. Can you help me please?
Is it support blackberry push notification?
Is it currently possible to set the certificate programmatically? We have a need to use multiple certificates which will be selected at runtime and not in the config file.
If not, I'll fork and implement.
Thanks
I just installed the package and did a simple implementation on my router as below:
Route::get('pusher', function(){
$deviceToken = '1234567890';
$push = PushNotification::app('appNameAndroid')
->to($deviceToken)
->send('Hello World, i`m a push message');
$response = $push->getAdapter()->getResponse();
// $response = $push->getAdapter()->getFeedback();
return $response;
});
I got the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Call to undefined method Davibennun\LaravelPushNotification\App::getAdapter()
highlighting the $response = ... line
I have also published my config file and added the android apiKey. What could I be missing?
Hi folks!
I decide to use this package for my push notification sender.
So, I use it. The message arrives in iPhone, but I have this error
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
HELP
Maximum execution time of 30 seconds exceeded
protected function read($length = 1024)
{
if (!$this->isConnected()) {
throw new Exception\RuntimeException('You must open the connection prior to reading data');
}
$data = false;
if (!feof($this->socket)) {
$data = fread($this->socket, (int) $length); //<--- error
}
The strange is that it works perfectly, but I had this error.
My code
$message = PushNotification::Message('Message!!!',array(
'badge' => 1,
'sound' => 'default',
));
$push = PushNotification::app('ios');
$push->to('09008c27079f7acf592aa7a31345b93b47089ac84721aff4478eXXXXXe19')->send($message);
My conf
return array(
'ios' => array(
'environment' =>'development',
'certificate' =>app_path().'/assets/apple_push_notification_production.pem',
'passPhrase' =>'XXXXX',
'service' =>'apns'
),
'android' => array(
'environment' =>'production',
'apiKey' =>'yourAPIKey',
'service' =>'gcm'
)
);
Any idea?
Please can you help me figure that thing out. I am using laravel 4.1
Hello,
Me and my company are getting ready to integrate Push Notifications into our application. However, we are developing on Laravel 5. Is there an ETA on getting this updated to be compatible with L5?
Cheers,
Andrew
What about use PSR-4 instead of PSR-0?
is there any way to solve error " Verify return code: 20 (unable to get local issuer certificate) " by passing an additional parameter?
depth=1 C = US, O = "Entrust, Inc.", OU = www.entrust.net/rpa is incorporated by reference, OU = "(c) 2009 Entrust, Inc.", CN = Entrust Certification Authority - L1C
verify error:num=20:unable to get local issuer certificate
verify return:0
OS: Ubuntu 14.04 / LEMP
Here is how I test connection:
openssl s_client -connect gateway.push.apple.com:2195 -cert push.pem -key push.pem
I also ran these in /etc/ssl/certs/ directory
wget https://www.entrust.net/downloads/binary/entrust_2048_ca.cer -O - > entrust_root_certification_authority.pem
echo >> entrust_root_certification_authority.pem
wget https://www.entrust.net/downloads/binary/entrust_ssl_ca.cer -O - >> entrust_root_certification_authority.pem
related thread:
zendframework/zendframework#5870
How do I specify the android application package name? I need it to send push notifications.
When i dump the response it givee me MismatchSenderId error
What can be the issue ??
Also how can we access the properties of the response ?
here is my code for getting response
// get response for each device push
foreach ($ret_collection->pushManager as $push) {
$response = $push->getAdapter()->getResponse();
var_dump($response);
}
I'm getting this error:
AdapterException in Push.php line 89: Adapter Gcm does not support edPFWelGppM:APA91bHJVSV3IUmXP1Lsr... token's device
I use Laravel 5
Here my code that cause error:
$registrationIds = 'myDeviceTokenId'; $msg = 'Houston we had a problem ...'; $fields = ['registration_ids' => $registrationIds, 'data' => $msg ]; // access to adapter for advanced settings $push = PushNotification::app('appNameAndroid'); $push->adapter->setAdapterParameters([ 'sslverifypeer' => false, 'post' => true, 'returntransfer' => true, //'post_fields' => json_encode($fields), ]); $push->to($registrationIds); $push->send($msg, []);
If I use this simple script to send an Android push notification, it work well.
https://gist.github.com/prime31/5675017
I've test on both local Ubuntu and server CentOS machine:
Linux version 3.10.0-123.20.1.el7.x86_64 ([email protected]) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Thu Jan 29 18:05:33 UTC 2015 Linux version 3.2.67-mykernel (root@nickfarrow-3500) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #3 SMP Fri Mar 27 19:53:37 ICT 2015
My push-notification.php setting:
'appNameIOS' => array( 'environment' =>'development', 'certificate' =>config_path().'/certificate/key.pem', 'passPhrase' =>'12345678', 'service' =>'apns' ), 'appNameAndroid' => array( 'environment' =>'production', 'apiKey' =>'AIzaSyA__***', // yourAPIKey 'service' =>'gcm' )
My composer.json
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "laravel/framework": "5.0.*", "jenssegers/agent": "^2.1", "fzaninotto/faker": "^1.5", "barryvdh/laravel-debugbar": "^2.0", "illuminate/html": "^5.0", "davibennun/laravel-push-notification": "dev-laravel5" }, "require-dev": { "phpunit/phpunit": "~4.0", "phpspec/phpspec": "~2.1", "xethron/migrations-generator": "dev-l5", "way/generators": "dev-feature/laravel-five-stable", "sboo/multiauth" : "4.0.*" }, "autoload": { "classmap": [ "database" ], "files": [ "app/helpers.php" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "classmap": [ "tests/TestCase.php" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-update-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "post-create-project-cmd": [ "php -r \"copy('.env.example', '.env');\"", "php artisan key:generate" ] }, "config": { "preferred-install": "dist" }, "repositories": [ { "type": "git", "url": "[email protected]:jamisonvalenta/Laravel-4-Generators.git" } ] }
I think this may be related to
Ph3nol/NotificationPusher#21
So I suggest to change vendor/sly/notification-pusher/src/Sly/NotificationPusher/Model/Push.php:
about line 89->
if($adapter->getAdapterKey() != "gcm") { // fix me : this is core modifying foreach ($devices as $device) { if (false === $adapter->supports($device->getToken())) { throw new AdapterException( sprintf( 'Adapter %s does not support %s token\'s device', (string) $adapter, $device->getToken() ) ); } } } //
Thank you very much!
Hi,
The "Symfony\Component\OptionsResolver\OptionsResolverInterface" interface was deprecated in version 2.6 and will be removed in 3.0. Use "Symfony\Component\OptionsResolver\OptionsResolver" instead.
I have set the cert in app/config/packages/davibennun/laravel-push-notifcation/config.php
and made a testing function like this and hardcoded the devicetoken to it.
\PushNotification::app('CP2')->to("mydevicetoken")->send('Hello World, i`m a push message');
the function run without error, but my iphone didnt' get the notification.
how can I troubleshoot this issue??
config :
'appNameIOS'=>array( 'environment' => 'development', 'certificate' => base_path(). '\pushProd.pem', 'passPhrase' => '', 'service' => 'apns' )
and PushNotification::app('appNameIOS')->to("FA87F3994E03640A370F4EC5E5F2337B5CCBF4A155595FADDBE81DCD0DF47A03") ->send('Hello World, im a push message');
it got error, sorry i don't know english
Trying (in Laravel 4.1)
php artisan config:publish davibennun/laravel-push-notification
results in
[InvalidArgumentException] Configuration not found
Please tell me how to check notification sent or not
I just try pushing my code base to my hosting provider and I got an error. That your package requires php version 5.4.0 but when I change my php version, the push command hangs and indicates it cannot find php command, Pagoda Box is my hosting provider, my request is can you give me the version number for the previous one before these changes today.
I am using laravel 4.1
I get an issue when trying to install for Laravel 4.1.x:
Problem 1
- zendframework/zend-json dev-develop requires zendframework/zend-stdlib dev-develop -> no matching package found.
- sly/notification-pusher v2.2.4 requires zendframework/zendservice-google-gcm 1.* -> satisfiable by zendframework/zendservice-google-gcm[1.0.1].
- zendframework/zendservice-google-gcm 1.0.1 requires zendframework/zend-json >=2.0.0 -> satisfiable by zendframework/zend-json[2.3.x-dev].
- davibennun/laravel-push-notification dev-master requires sly/notification-pusher 2.* -> satisfiable by sly/notification-pusher[v2.2.4].
- remove zendframework/zend-json 2.3.x-dev|keep zendframework/zend-json dev-develop
- Installation request for davibennun/laravel-push-notification dev-master -> satisfiable by davibennun/laravel-push-notification[dev-master].
Hello.
I try to send ios push with loc-key parameters.
Davibennun can't send alert = array(loc-key=>'sometext');
I get exception as "cannot conver array to string".
LPL packet can't get hash for array too..
But it necessary for push localisation as lock-key parameter in alert.
please extend functional for alert ios value or as array type or as json text.
Thank you VMch!
And thank you for your good laravel plugin. :)
I got this error Ph3nol/NotificationPusher#21 ,
and the fix consists of calling gcm's adapter method setAdapterParameters(['sslverifypeer' => false])
In my understanding, there is no way to access the adapter object in your lib right ?
So I suggest to change App constructor:
public function __construct($config){
$this->pushManager = new PushManager($config['environment'] == "development" ? PushManager::ENVIRONMENT_DEV : PushManager::ENVIRONMENT_PROD);
$service = $config['service'];
$adapterClassName = 'Sly\\NotificationPusher\\Adapter\\'.ucfirst($service);
$adapterConfig = $config;
unset($adapterConfig['environment']);
unset($adapterConfig['service']);
$this->adapter = new $adapterClassName($adapterConfig);
if ($service === 'gcm') {
$this->adapter->setAdapterParameters(array('sslverifypeer' => false));
}
}
Hi guys,
Ii ran composer update to get library
"require": {
"laravel/framework": "4.2.*",
"davibennun/laravel-push-notification": "dev-master"
.......
This is error:
Problem 1
- Installation request for davibennun/laravel-push-notification dev-master -
satisfiable by davibennun/laravel-push-notification[dev-master].
- davibennun/laravel-push-notification dev-master requires sly/notification-
pusher 2.* -> no matching package found.
Potential causes:
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common
problems.
Please say me why? and how to fix?\
Thanks so much!
after composer update throw
Exception: Class pushNotification does not exist
Skipping \Davibennun\LaravelPushNotification\Facades\PushNotification.
WTF?!
change pushNotification to PushNotification
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.