laravel-notification-channels / apn Goto Github PK
View Code? Open in Web Editor NEWAPN push notifications channel for Laravel
Home Page: http://laravel-notification-channels.com
License: MIT License
APN push notifications channel for Laravel
Home Page: http://laravel-notification-channels.com
License: MIT License
I'm implementing safari push notifications, the thing is I can get the device token from my Mac, but I'm not able to send notifications via this channel. I am using it for a web app, so I was wondering maybe this package cant be used for sending from websites to macOS, or I need the ios push certificate and the website push certificate? Currently, I am using one certificate(website push) to generate the push package and to send notifications to APN.
spn
In the docs, it still states that "NotificationChannels\Apn\ApnServiceProvider::class" needs to be registered in app.php, but it appears this file was removed for the 0.2.0 release.
Is it still needed, or does this just need to be removed from the docs?
Hi, I have a question about the library. I created the .pem certificate and when doing the command "openssl s_client -cert Push.pem -connect gateway.push.apple.com:2195" this has not occurred any error so I suppose it is ok. I have continued to configure broadcasting and created the notification but it has not worked.
In my broadcasting:
'apn' => [ 'environment' => NotificationChannels\Apn\ApnChannel::PRODUCTION, // Or ApnChannel::SANDBOX 'certificate' => base_path('Push.pem'), 'pass_phrase' => null, ],
In my notification:
`namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log;
use NotificationChannels\Apn\ApnChannel;
use NotificationChannels\Apn\ApnMessage;
class ApnPushPruebaNotification extends Notification
{
use Queueable;
public function via($notifiable)
{
return [ApnChannel::class]; // Make sure you use 'ApnChannel::class', not just 'apn'
}
public function toApn($notifiable)
{
return ApnMessage::create()
->badge(1)
->title('Account approved')
->body("Your {$notifiable->service} account was approved!");
}
}`
in my notifiable (User):
`
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use Notifiable;
protected $table = 'users';
protected $fillable = [
'name',
'email',
'phone',
'photo',
'password',
'type',
'apn_token'
];
public function routeNotificationForApn()
{
return $this->apn_token;
}
}`
and the function in controller (with "use App\Notifications\ApnPushPruebaNotification") :
`
public function test()
{
$user = Auth::user();
$user->notify(new ApnPushPruebaNotification());
}
`
My question is where do I get the apn tokens? For knowing if that fails, or is something else, thanks for the help.
Would it be possible to get an actual release tagged for this repository? Current in Composer we're being forced to pull in the @dev release, which is never a great idea for a production application.
I'm not sure if there's a reason a specific release hasn't been tagged, but if not it would be preferable to pulling in the latest @dev for sure.
Presently, to send these APN notifications, our via
function will look something like this:
public function via($notifiable)
{
return [ApnChannel::class];
}
However, I want to be able to send them like this:
public function via($notifiable)
{
return ['apn'];
}
How can this be achieved?
So basically, I want to be able to give a custom name of this APN notification channel called "apn
". I looked in the Laravel documentation and it does not seem to be explained how to achieve this, and I also dug into the code a little bit but can't seem to figure it out. It seems like this should be a trivial thing but apparently it's not. If anyone knows how this can be achieved, please post here. If it works well and is agreed to upon by this community potentially we can do a pull request. If for some reason this is not desired or bad practice, please explain why. Either way, it would be nice if this could be achieved.
Thanks for any insight or help you may provide.
Hi there,
After I add Apn record into config/broadcasting.php
I got an exception "Class 'ApnChannel' not found"
I have tried adding the path "vendor/laravel-notification-channels/apn/src" to composer.json
"autoload": { "psr-4": { "App\\": "app/" }, "classmap": [ "database/seeds", "database/factories", "vendor/laravel-notification-channels/apn/src" ] },
and running artisan package:discover, it does show
Discovered Package: laravel-notification-channels/apn
However, still gives 'Class not found' issue. Any help much appreciated!
Laravel 5.8
It appears that the latest version, v0.4.0 (https://github.com/laravel-notification-channels/apn/releases/tag/v0.4.0) isn't showing in Packagist. Is there something that needs to be done in order to get that to show as available?
This is more of a PSA than an actual issue, but I felt it make sense to open this. Since the switch to using Pushok for sending notifications, this package currently does not work with Laravel Vapor.
This is due to Pushok requiring curl being compiled with HTTP/2 enabled, and Vapor (currently) not meeting this requirement. I have submitted a ticket to the Vapor team (about a week ago) regarding this, but as of now have not received a response to it.
This is an issue, because in order to upgrade to Laravel 7, we're required to use >= v2.0.0 of this package, which is currently not possible due to the Pushok incompatibility.
It seems to me there are 3 possible solutions here:
1 and 2 are certainly better solutions, but for the time being we're stuck on Laravel 6 since we're using Vapor for our environment.
I don't understand where to use the feedback service. Is it in a controller?
how is that url registered?
Is it in a service provider? Expanding the docs on this would be veru useful and appreciated.
Looks like the sync between GitHub releases and Packagist isn't working anymore and needs to be updated to use the newer webhooks method. This will allow us to keep publishing new versions.
@themsaid I believe you're the admin of the package on Packagist - would you be able to update the webhook, or add me as a maintainer on Packagist (dwightwatson) so that I can sort it out going forward?
Relevant: #60
Using the package for the while, and i found that we cannot set the expire for the Message
can you update, so we can set the expire value
thank you and cheers ^^
the library does not support pushs in background in ios 13, it works fine when set content availble as 1 and send no title and body in olders system version of ios 12 or lower, but when using ios 13 it does not work fine
I'm using Notification::fake() to test the notifications but it looks like it does something since the test takes about 800ms to complete, when the other tests that are not using notifications just take 200ms
Let me know if there is anything I can to to verify that is doing something with the network
Thanks!
Hi,
I'd like to use diferent certificates with your package. Is there any way to achieve this?
I'm using one normal notification certificate and I want to add a passKit certificate to notify iOS wallet for updates. It can not be the same...
APNS requires implementation of receiving feedback. Upstream ZendService
has the classes Client\Feedback
and Response\Feedback
for this purpose. If this is not implemented, Apple can by their means to invalidate the certificates used.
I'm getting this error message and by digging further it looks like this package doesn't allow to send notifications to multiple users at once. If i send a notification to a single user no problem is encountered, when I want to send multiple notifications to multiple users at once, it fails.
Indicated in my pull request
I'm referencing to this part:
Line 89 in b8f4510
Should this not OpenConnection/CloseConnection outside of the foreach loop?
In some cases, when just testing the correct payload of the notification, I think it would be useful to have the notification logged instead of actually sent out.
What do you think? Do you have any suggestions on how I could test notifications without actually sending them?
I think it would be a good idea to add composer.lock file to git as recommended here
This way we'll be using exactly the same packages version!
Thanks!
Problem is when I am trying to send message to an array of tokens.if there is any problem in sending message to a device token,whole process would fail and next tokens wouldn't even proceeded.
i got the exception like "App\Pushok\Client".
if use the token & client class like this "use Pushok\Client;
use Pushok\AuthProvider\Token;"
$customClient = new Client(new Token($options));
i got some other exception
Call to private Pushok\AuthProvider\Token::__construct() from context
Where i need to create custom client from my Notification class Or from ApnServiceProvider?
Hello,
I have used this package in my project, i have followed the installation guide properly but i am getting an error
Unresolvable dependency resolving [Parameter #2 [ $environment ]] in class NotificationChannels\Apn\ApnChannel
and i am not able to solve it.
If anyone can guide me it will be a great help.
ApnChannel.php, line 48: $this->passphrase -> $this->passPhrase
It's not enough just to specify a voip
push type to turn a traditional push notification into a VoIP push notification. Every iOS device has two different device tokens: alarm
(normal) and voip
. So both should be stored in the DB and retrieved by the routeNotificationFor...
method. Apparently, something like a new routeNotificationForApnVoip
method is needed.
I need to send notifications to multiple users at same time. could you please help me to resolve this. if you have any example application it will be helpful for me. thanks
Does anyone see some tasks required to do to fully support this?
In order to support ios13 we need to add "apns-push-type" header.
Is this library supports it?
I'm using this package version v1.3.0 with Lumen 6 because Lumen 7 hasn't been released yet.
If I use a pushType()
method to send voip
notifications I get a DeviceTokenNotForTopic
error. But if I change APN_BUNDLE_ID
env var by adding a .voip
suffix it starts working. Apparently, edamov/pushok supports this case.
ApnMessage::create()
->pushType('voip')
->badge(1)
->title('Incoming call')
->body('Something here!');
Hello, I would like to know if it is necessary to enable push notifications in my app. I have never used Xcode and I don't know if I can activate this feature to my Laravel project.
I would like to create critical alerts (see https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification#2990112).
I need to include the "critical" and "volume" flag in the sound dictionary. As I see it is only possible to set a sound name.
Is it possible to add this flag?
Since Apple has simplified the way developers send notifications with a .p8 auth key. Any plan if this will be brought into this repository?
Consider the case, if there are multiple mobile apps for different usertypes. So the certificate files will be different. So how the configuration can be switched?
i couldn't install (apn v2) this package in laravel 6.
function routeNotificationForApn() in the User model returns array of push_tokens.
If the user has array of tokens (several devices), and one of them is wrong - no one devices will be notified.
I'm upgrading a project to laravel-notification-channels/apn 1.3.0 (Laravel 6) and it appears that the service provider is hardcoded on Token
with no way to use the Certificate
class of edamov/pushok without writing an override service.
Is my understanding correct? And is that a bug, or is it a feature that is supposed to force me to get some new stuff from Apple?
I am writing a cron job that will run on a specific time every day and send all user to push notification but i am not receiving a push notification on an iOS device.
This is my kernel.php file code
protected function schedule(Schedule $schedule) { $schedule->command('er:send-push-notification') ->dailyAt('13:00'); }
this is my code in my ErCronJob.php
public function handle() { $users = User::whereIn('role_id', [2, 3, 4])->where('mobile_number', '9985353442')->get(); foreach ($users as $user) { $message = $this->info('Hello user you got a new notification'); $user->notify(new SendDailyComplaintStatisticsToErs($message)); } }
This is my code in SendDailyComplaintStatisticsToErs.php
public function toApn($notifiable) { return ApnMessage::create() ->badge(1) ->title('Account approved') ->body("Your account is approved!"); }
When i dump my last code i am getting below mention message.
Can anyhelp me with this. Thanks**
Just installed the package, and I notices that there isn't the getFeedback
method,
I found that it is because in 0.1.0 wasn't there, but it is on the master now,
can you update the tag so we can get the feedback and remove the apropiate tokens?
Thanks!
Let me know when you're done with the initial code / tests / readme. I'll do a code review and set up packages, and other services
Since a user can have multiple devices associated to them, some systems store preferences for each device instead of the user itself. It can happen that different devices of a same user use a different API version that needs a different notification payload.
This package already allows to send a notification to multiple devices for the same user at once. I think the next logical step would be to allow to send a different message for each device. What do you think?
Since I'm using a worker to send the notification.
the token eventually expires. Should there be a way to refresh it?
Per apple doc, you have to refresh Token every 20-60 mins
Hi could you create a new release with recent changes?
Thanks
i have two applications with single back end. so i want to use multiple bundle ids to send push notifications to the ios devices. can you please help me to resolve this asap. thanks
Is it necessary to send apns-topic?
I read on Apple developer that the legacy (binary/http1.1) api would be deprecated in November 2020.
Is this plugin using the new HTTP/2 API?
Full disclaimer: I'm new to both notifications and queues.
I can send APN notifications just fine without the queue. When I implement ShouldQueue
my queues are created and fired, but $notifiables
is empty in SendQueuedNotifications.php
I posted about this on the Laracasts forum.
My assumption is that adding implement ShouldQueue
is what I'm supposed to do to get these notifications to queue*. After a day of banging my head on my desk trying to find out where this is failing, I'm completely unsure where else I should be looking.
*Edit: and they are queueing. I am using the database driver locally and beanstalkd on my server. The rows are being created, and removed when I php artisan queue:work
I've logged and debugged up and down and see that $notifiables
is empty in SendQueuedNotifications.php
when the queue fires.
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.