Giter VIP home page Giter VIP logo

webpush's People

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

webpush's Issues

For multi-tenant application

I am trying your webpush package for my one of application.
My application has Multi-tenant schema's as diff. database.

The issue is there is no option to pass database connection for PushSubscription model.
How can i do that?

Action Option Not working

When Providing action like this:

return WebPushMessage::create()
// ->id($notification->id)
->title('Approved!')
->icon('/approved-icon.png')
->body('Your account was approved!')
->action('View account', 'view_account');

action option not working. Does not show any action.

When i click on notification. I use notificationclick event listener and console, the event. In event action array is empty. Please fix this or explain how can i do this. I want to pass url in action

Encrypting notifications

I think I have it running quite smoothly in my app, this Webpush thing. That's great.

However, somehow, my Webpush notifications don't seem to have a payload... I understand from the docs that's only possible if the subscription is correctly encrypted. Now I am a bit lost as I thought I was doing this correctly.

My use case is the following:

On the client I use the web-push module and I create a subscription from the service worker using pushManager.subscribe passing the public VAPID key (convert to Uint8 array). The subscription is created successfully having an endpoint and two keys (p256dh and auth).

I send the subscription to my server to store it in the push_subscription table using the command in the docs, i.e., $user->updatePushSubscription($endpoint, $key, $token);

I am not totally sure which of the two keys mentioned should go as the second and third argument though. I looked into the source code of the demo, and figured I should do

$key = p256dh
$token = auth

However, although my subscription seems to work (I have working Push messages), when I log my PushEvent in the browser devtools, the PushMessageData is empty.

Any thoughts on this?

Pushing to single endpoints

Is it possible to push a notification out to a single endpoint, rather than all endpoints belonging to a user?

For example, the user might have requested notifications be sent to their desktop and mobile but only wants certain notifications sent to their mobile. Or maybe sending out a test notification upon registering a device - you'd only want those on the device just registered.

400 UnauthorizedRegistration

I had this working on my local machine yesterday. Today I started working with it again and the notifications stopped appearing.

After some investigation I was able to log the response in the WebPushChannel send method. The endpoint is returning a 400 UnauthorizedRegistration response.

Any idea why this would happen?

Actions Still not working after update

return (new WebPushMessage)
// ->id($notification->id)
->title($this->title)
->icon(url('/img/push_notification.png'))
->body($this->body)
->action('View account','view_account');

screenshot_1

Send additional data / payload

Is it possible to send additional data with the push message, besides the following five attributes?

return WebPushMessage::create()
            // ->id($notification->id)
            ->title( $this->notification_data['push_title'] )
            ->icon( $this->notification_data['push_icon'] )
            ->body( $this->notification_data['push_body'] );
//            ->action('View account', 'view_account');

What I'm trying to do is send a user picked URL to the push notification, so that I can respond by opening up that specific URL when a user clicks on the notification.

Thanks again for the great job you did with this library!

max execution time

I'm sending lots of push messages at one (around 5.000) and I'm getting the error: Symfony\Component\Debug\Exception\FatalErrorException: Maximum execution time of 120 seconds exceeded
in vendor/mdanter/ecc/src/Math/GmpMath.php:34

Any idea how I can solve that?

install using composer

I tried to install your package by composer by I got this error:

Problem 1 - mdanter/ecc v0.4.2 requires ext-gmp * -> the requested PHP extension gmp is missing from your system. - mdanter/ecc v0.4.1 requires ext-gmp * -> the requested PHP extension gmp is missing from your system. - mdanter/ecc v0.4.0 requires ext-gmp * -> the requested PHP extension gmp is missing from your system. - laravel-notification-channels/webpush 0.1.1 requires minishlink/web-push 1.1.* -> satisfiable by minishlink/web-push[v1.1]. - minishlink/web-push v1.1 requires mdanter/ecc ^0.4.0 -> satisfiable by mdanter/ecc[v0.4.0, v0.4.1, v0.4.2]. - Installation request for laravel-notification-channels/webpush ^0.1.1 -> satisfiable by laravel-notification-channels/webpush[0.1.1].

Driver WebPushChannel not supported.

local.ERROR: InvalidArgumentException: Driver [NotificationChannels\WebPush\WebPushChannel] not supported. in /var/www/tallybox/vendor/laravel/framework/src/Illuminate/Support/Manager.php:91

Any idea what is happening?

app.js:33556 WebSocket connection to 'ws://ws.pusherapp.com/app/67006e7ceebb6ff4d753' failed: Invalid frame header

I have installed your Laravel package for pusher in my application. however, i am getting the issue as

app.js:33556 WebSocket connection to 'ws://ws.pusherapp.com/app/67006e7ceebb6ff4d753?protocol=7&client=js&version=4.2.2&flash=false' failed: Invalid frame header

WebSocket connection to 'ws://ws.pusherapp.com/app/67006e7ceebb6ff4d753?protocol=7&client=js&version=4.2.2&flash=false' failed:

WebSocket is closed before the connection is established.

Whereas "Enable Push Notification" Button is always disabled. Please let me know how I can solve this issue.

Action Option function not working

Action Option function not working

php code

public function action($title, $action)
{
$this->actions[] = compact('title', 'action');

    return $this;
}

Js code
if (event.data) {
var data = event.data.json();

const title = data.title;
const options = {

body: data.actions,
icon: data.icon,
actions: [
{
action: data.icon,
title: 'Coffee',
icon: data.action
}],
}

self.registration.showNotification(title,options);

php artisan webpush:vapid issue

I installed it as specified in the readme.md but when it is time to run php artisan webpush:vapid i get this error:
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Mdanter\Ecc\EccFactory' not found

at C:\xampp\htdocs\Falanga\vendor\minishlink\web-push\src\VAPID.php:145

141|      * @return array
142|      */
143|     public static function createVapidKeys()
144|     {

145| $privateKeyObject = EccFactory::getNistCurves()->generator256()->createPrivateKey();
146|
147| return self::getUncompressedKeys($privateKeyObject);
148| }
149|

Exception trace:

1 Minishlink\WebPush\VAPID::createVapidKeys()
C:\xampp\htdocs\Falanga\vendor\laravel-notification-channels\webpush\src\VapidKeysGenerateCommand.php:33

2 NotificationChannels\WebPush\VapidKeysGenerateCommand::handle()
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29

3 call_user_func_array([])
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29

4 Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:87

5 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:31
6 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Container\Container.php:564

7 Illuminate\Container\Container::call()
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Console\Command.php:184

8 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
C:\xampp\htdocs\Falanga\vendor\symfony\console\Command\Command.php:251

9 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Console\Command.php:171

10 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\xampp\htdocs\Falanga\vendor\symfony\console\Application.php:886

11 Symfony\Component\Console\Application::doRunCommand(Object(NotificationChannels\WebPush\VapidKeysGenerateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Obj
ect(Symfony\Component\Console\Output\ConsoleOutput))
C:\xampp\htdocs\Falanga\vendor\symfony\console\Application.php:262

12 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\xampp\htdocs\Falanga\vendor\symfony\console\Application.php:145

13 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Console\Application.php:89

14 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\xampp\htdocs\Falanga\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:122

15 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\xampp\htdocs\Falanga\artisan:37

Please tell me if you need any additional information

Move composer requirement from Laravel 5.3 to 5.3 or 5.4?

Is there a way to also allow this module to be used in the recently released laravel 5.4?

Problem 1 - Installation request for laravel-notification-channels/webpush ^0.1.1 -> satisfiable by laravel-notification-channels/webpush[0.1.1]. - Conclusion: remove laravel/framework v5.4.3 - Conclusion: don't install laravel/framework v5.4.3

URL in action is not woking ?

URL defined in action is not working for me. Here is my code.

public function toWebPush($notifiable, $notification)
{
return (new WebPushMessage)
->title('Title section is here!')
->icon('/images/logo.png')
->body('Here is my body section.' )
->action('View app', 'http://127.0.0.1:8000/dashboard/');
}

I am getting push notification but once I click on the popup it redirects to the base URL. In above, it redirects to the base URL (i.e. http://127.0.0.1:8000) where I wanted to redirect to the dashboard page.

Help me out from this issue.
Thanks in advance.

Problem with notification content

Hi, I'm having a problem with notifications.

Be aware that I'm using Lumen, not Laravel. I installed and configured anything I needed to make this library working with Lumen (at least I think so)

What works:

  • Subscriptions are correctly saved in the Database.
  • When I do $user->pushSubscriptions on a test user, it shows me the correct data.
  • Notifications are SENT, i receive them on chrome desktop or chrome android.

Problem : BUT, I have no content in the notifications. The only infos I have in the notifications are:

  • app url
  • "This site has been updated in the background" message

It looks like to me that no content is added on the payload, and maybe that's why chrome just display a default message

NotificationController.php send() function (my entry point in the router to send my test notifications):

public function send()
    {
        $user = User::find('2');
        $user->notify(new PushNotification);
        return response()->json('test', 201);
    }

PushNotification class (some parts of it):

public static function via($notifiable)
{
    return [WebPushChannel::class];
}

/**
 * Get the array representation of the notification.
 *
 * @param  mixed  $notifiable
 * @return array
 */
public function toArray($notifiable)
{
    return [
        'title' => 'Hello from Laravel!',
        'body' => 'Thank you for using our application.',
        'action_url' => 'https://laravel.com',
        'created' => Carbon::now()->toIso8601String()
    ];
}

/**
 * Get the web push representation of the notification.
 *
 * @param  mixed  $notifiable
 * @param  mixed  $notification
 * @return \Illuminate\Notifications\Messages\DatabaseMessage
 */
public function toWebPush($notifiable, $notification)
{
    return (new WebPushMessage)
        ->title('Approved!')
        ->icon('/approved-icon.png')
        ->body('Your account was approved!')
        ->action('View account', 'view_account');
    // ->data(['id' => $notification->id])
    // ->badge()
    // ->dir()
    // ->image()
    // ->lang()
    // ->renotify()
    // ->requireInteraction()
    // ->tag()
    // ->vibrate()
}

As you can see, I tried to do exactly like in the example.

I have been spending hours trying to make it work, with no success. Any help would be greatly appreciated.

On vendor:publish - FatalErrorException

Hi,
I'm using 5.2 with backport package, as instructed. at time of publishing i have followed same steps as instructed by you: php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="migrations"
I have received below error, kindly suggest me what i need to do?

[Symfony\Component\Debug\Exception\FatalErrorException]
Class NotificationChannels\WebPush\WebPushServiceProvider contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Suppo
rt\ServiceProvider::register)

artisan migrate don't work

Show this:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table push_subscriptions add unique push_subscriptions_endpo int_unique(endpoint))

Question: How to segment push messages

Hi @cretueusebiu !

First of all, nice work on the vapid-update. I've implemented your library and it works great.
Right now, I'm trying to segment the push subscriptions, so that I can send only to some of them, not all of them.

Right now, when using the laravel notification, the push messages are sent to all subscriptions for a user. What I'm trying to do is keep track of subscriptions with a tag like "segment1", "segment2" and only target those subscriptions.

What would be a good way to approach this? My current approach would be to extend/overwrite your send function in WebPushChannel.php.

I know this isn't an issue with the library, so if you don't have time to reply to this question I understand completely!

customer user tables and primary id

i am using a customer table with UUID instead of interger id's and I am getting -

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer_users_id' in 'field list'

Can i make changes outside the provider files so as not to break the code.

[Question] Do pushes have to be tied to a 'user' model?

First off, thanks so much for this package and the others for each provided channel. You all rock.

Is there any way to use this package without strongly tying push notifications to the users table. I'm currently working on an app where people can subscribe to web push notifications without creating an account. They're saved in a completely different entity, "Contacts", and are not saved in the users table.

The problem lies in that it looks like everything in this package is strongly tied to a User model and has a hard coded 'users' table in the migration and a user_id on the PushSubscription model.

If not, I guess I can implement this using the webpush library directly, but wanted to ask first. Thanks again.

Rows Deleted

Hi, I have an issue, when I send the notification to all users some rows deleted in the push_subscriptions table without any reason, including my mobile maybe I was turning off the internet when the notification sent , and when I compare users table and push_subscriptions table I found more than 80 records missing, please how can I disable the deletion procedures in push_subscriptions?

migrations not being generated

First of all, thanks so much for taking the effort to upgrade to VAPID!

I'm currently trying out the new release, but noticed that there are not migrations being generated.

vagrant@server:~/Code/$ php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="migrations"
Publishing complete.
vagrant@server:~/Code/$ php artisan migrate
Nothing to migrate.

Is that something I'm missing? I'm sure there are some default tables or columns you're generating normally?

Thanks again!

Add to readme.md please

// Add to api.php

Route::post('/save-subscription/{id}',function($id, Request $request){
  $user = \App\User::findOrFail($id);

  $user->updatePushSubscription($request->input('endpoint'), $request->input('keys.p256dh'), $request->input('keys.auth'));
  $user->notify(new \App\Notifications\AccountApproved());
  return response()->json([
    'success' => true
  ]);
});

// Create public/js/service-worker.js

self.addEventListener('push', function(event) {
  if (event.data) {
    var data = event.data.json();
    self.registration.showNotification(data.title,{
      body: data.body,
      icon: data.icon
    });
    console.log('This push event has data: ', event.data.text());
  } else {
    console.log('This push event has no data.');
  }
});

// Add to your main.blade header

<script>
window.Laravel = {!! json_encode([
    'user' => Auth::user(),
    'csrfToken' => csrf_token(),
    'vapidPublicKey' => config('webpush.vapid.public_key'),
    'pusher' => [
        'key' => config('broadcasting.connections.pusher.key'),
        'cluster' => config('broadcasting.connections.pusher.options.cluster'),
    ],
]) !!};
</script>

// Access & Subscribe to backend examples js

var Noty = function(){
var _registration = null;

    var notify = function() {
        registerServiceWorker();
        if(AUTH) {
            setInterval(askPermission(), 1000*60*30);
        }
    }
    var registerServiceWorker = function() {
        return navigator.serviceWorker.register('js/service-worker.js')
            .then(function(registration) {
                console.log('Service worker successfully registered.');
                _registration = registration;
                return registration;
            })
            .catch(function(err) {
                console.error('Unable to register service worker.', err);
            });
    }

    var askPermission = function() {
        return new Promise(function(resolve, reject) {
                const permissionResult = Notification.requestPermission(function(result) {
                    resolve(result);
                });

                if (permissionResult) {
                    permissionResult.then(resolve, reject);
                }
            })
            .then(function(permissionResult) {
                if (permissionResult !== 'granted') {
                    throw new Error('We weren\'t granted permission.');
                } else {
                    subscribeUserToPush();
                }
            });
    }

    var urlBase64ToUint8Array = function(base64String) {
        const padding = '='.repeat((4 - base64String.length % 4) % 4);
        const base64 = (base64String + padding)
            .replace(/\-/g, '+')
            .replace(/_/g, '/');

        const rawData = window.atob(base64);
        const outputArray = new Uint8Array(rawData.length);

        for (let i = 0; i < rawData.length; ++i) {
            outputArray[i] = rawData.charCodeAt(i);
        }
        return outputArray;
    }

    var getSWRegistration = function() {
        var promise = new Promise(function(resolve, reject) {
            // do a thing, possibly async, then…

            if (_registration != null) {
                resolve(_registration);
            } else {
                reject(Error("It broke"));
            }
        });
        return promise;
    }

    var subscribeUserToPush = function() {
        getSWRegistration()
            .then(function(registration) {
                console.log(registration);
                const subscribeOptions = {
                    userVisibleOnly: true,
                    applicationServerKey: urlBase64ToUint8Array(window.Laravel.vapidPublicKey)
                };

                return registration.pushManager.subscribe(subscribeOptions);
            })
            .then(function(pushSubscription) {
                console.log('Received PushSubscription: ', JSON.stringify(pushSubscription));
                sendSubscriptionToBackEnd(pushSubscription);
                return pushSubscription;
            });
    }

    var sendSubscriptionToBackEnd = function(subscription) {
        return fetch('/api/save-subscription/'+window.Laravel.user.id, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json'
                },
                body: JSON.stringify(subscription)
            })
            .then(function(response) {
                if (!response.ok) {
                    throw new Error('Bad status code from server.');
                }

                return response.json();
            });
    }
    return {
        init: function () {
            notify();
        }
    };
}();
$(function () {
    Noty.init();
});

GCM vs VAPID

Hi! I was wondering if GCM keys are a requirement? I found this Laravel library through https://github.com/web-push-libs/web-push-php where GCM is obsolete and not required. Having used the web-push-php library successfully with VAPID, I was wondering if GCM is still used here (also now that google is suggesting to drop GCM for FCM/firebase). Thanks for you input!

Move composer requirement from Laravel 5.4 to 5.5?

Is there a way to also allow this module to be used in the recently released laravel 5.5?

- laravel-notification-channels/webpush 0.2.0 requires illuminate/support 5.1.*|5.2.*|5.3.*|5.4.* -> satisfiable by laravel/framework[v5.4.36], illuminate/support[v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9].

Update readme

Browser compatibility includes Edge, Firefox, Chrome, and likely Safari. The README.md file does not indicate that.

Suggest updating the documentation to include that, as well as any other features that have been added since the package was released (if any).

Is it possible to send notifications only on mobile and not on desktop?

Can we send notifications to users only on mobile devices and not on desktop?

Also, notifications are currently sent on both mobile and desktop. So after dismissing a notification on mobile, I still see them on desktop, why so? I am talking about webpush notifications and not database notifications.

how to integrate with existing service worker in vue-cli PWA

I'm using vue-cli RC5 with the SPA/PWA template so I already have a service worker which is generated and managed entirely by the vue-cli default build process

in your tutorial it seems you create a service worker of your own, I am wondering if I can have two service workers or if I have to attach to the one created by vue-cli by modifying the default generated file

also.. if I understand correctly.. using Laravel as the "pusher" is an alternative to using something like OneSignal right?

Issue on composer install

Problem 1
    - minishlink/web-push v1.1 requires mdanter/ecc ^0.4.0 -> satisfiable by mdanter/ecc[v0.4.0].
    - laravel-notification-channels/webpush 0.1.1 requires minishlink/web-push 1.1.* -> satisfiable by minishlink/web-push[v1.1].
    - Installation request for laravel-notification-channels/webpush ^0.1.1 -> satisfiable by laravel-notification-channels/webpush[0.1.1].
    - Conclusion: remove paragonie/random_compat v2.0.4
    - Conclusion: don't install paragonie/random_compat v2.0.4
    - mdanter/ecc v0.4.0 requires paragonie/random_compat 1.4.1|2.0.2 -> satisfiable by paragonie/random_compat[v1.4.1, v2.0.2].
    - Can only install one of: paragonie/random_compat[v1.4.1, v2.0.4].
    - Can only install one of: paragonie/random_compat[v2.0.2, v2.0.4].
    - Installation request for paragonie/random_compat (locked at v2.0.4) -> satisfiable by paragonie/random_compat[v2.0.4].

Missing message attributes

You have taken body, actions, icon out of the options. I propose formatting it to follow the original structure listed below, this allows the user to choose from any of the options available instead of being constrained to the four you have included. Also this allows for future proofing as more options are added.

https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/showNotification

My current issue from this is that I want the user to be able to click on the notification and have it open to a webpage, which would require a URL which would go in the data section. Currently I am just going to edit it to include this attribute.

Not receiving Web Push Notification

I'm trying to test the push notifications. I have the registration process setup successfully, and print the subscription in the console, so I can hardcode the endpoint and call updatePushSubscription (see code below). The data is being stored in the DB table correctly.

Then I call the notify method. I put a Log in PushNotificaction.toWebPush() method, and it's being printed. However, I'm not receiving any notification at all on Chrome desktop when this happens. Any ideas where else I should be looking at?

$key = null;
$token = null;
$endpoint = 'https://fcm.googleapis.com/fcm/send/e0U-D7nEC4I:APA91bEi8Lfrh81XjxXr6Nc8LH4eJwzplaLvkjy8EYfKS-PUNHaUqnCUhlunAtjCUbrEPjLpy15TDc08m1a2J-EIDmJEyK6kdPeGSWCWaRcsxtwfmUwPHU9grqIOOBExygPt839LCf09';

Auth::User()->updatePushSubscription($endpoint, $key, $token);
Auth::User()->notify(new PushNotification);

Retest package

Hi @cretueusebiu

I've refactored some of your code.

If I've made a change that you don't like, let me know.

Could you test it again to make sure it works?

If possible, please add some automated tests.

String data, right truncated: 1406 Data too long for column 'endpoint' at row 1 ....

I have this error, when enabling subscriptions:

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'endpoint' at row 1 (SQL: insert into push_subscriptions (endpoint, public_key, auth_token, user_id, updated_at, created_at) values (https://fcm.googleapis.com/fcm/send/dqMhKLt8Lqs:APA91bFk7qwc4wjTz3nIy39fsaYa8T7cESKhqtDpYKW-DEGpMRca-8Dq0U95eDqZa3ZThv8rzdYXN23sN7w6yIVvTduOGpPGBRm5mhdpl4JPHd3PEwW7gfSrtxfVeHHaYnKhTGhRpwZiVrVnKg8x52TfGEdne54s-w, BMcmbRN2hb/BefieY2X8sX9Oys8WXEbpfQ7YqlmRI0+rBXJ7nHmg7fHmiN7Zj/sAJq9VMEIPHvjQ+ut9b4mi85g=, L938ikkhSJgrE3ZGWFe15A==, 1, 2018-08-06 19:16:41, 2018-08-06 19:16:41)) {"userId":1,"email":"[email protected]","exception":"[object] (Illuminate\Database\QueryException(code: 22001): SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'endpoint' at row 1 (SQL: insert into push_subscriptions (endpoint, public_key, auth_token, user_id, updated_at, created_at) values (https://fcm.googleapis.com/fcm/send/dqMhKLt8Lqs:APA91bFk7qwc4wjTz3nIy39fsaYa8T7cESKhqtDpYKW-DEGpMRca-8Dq0U95eDqZa3ZThv8rzdYXN23sN7w6yIVvTduOGpPGBRm5mhdpl4JPHd3PEwW7gfSrtxfVeHHaYnKhTGhRpwZiVrVnKg8x52TfGEdne54s-w, BMcmbRN2hb/BefieY2X8sX9Oys8WXEbpfQ7YqlmRI0+rBXJ7nHmg7fHmiN7Zj/sAJq9VMEIPHvjQ+ut9b4mi85g=, L938ikkhSJgrE3ZGWFe15A==, 1, 2018-08-06 19:16:41, 2018-08-06 19:16:41)) at /home/sanocloud/webapps/mysano/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 22001): SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'endpoint' at row 1 at /home/sanocloud/webapps/mysano/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458)

Error While install composer

To enable extensions, verify that they are enabled in your .ini files:
- E:\My-PC\xampp\php\php.ini
You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

how to solve this.

New Feature request: Add Edge support

Firefox and Edge are both at the bottom of the market share, but at least Firefox has support. Understanding that Edge is, well, Edge, do you have plans to add that feature to this package?

Add notification to guest

Thanks for this nice library , I already download the demo and try it , but actually I am working with project need to let visitors enable notification without register or do anything else , how can I do that with this library ?

`toWebPush` function of Notification is not called

Hi, I can dispatch events using pusher as broadcaster. But when I try to notify user using WebPush, the toWebPush function of Notification is not called. If I log some information on this function is not written on the log and, of course, pusher debugger console does not show the message.

Notification class code

public function via($notifiable)
    {
        return [
//            'mail',
//            'nexmo',
            WebPushChannel::class
        ];
    }

public function toWebPush($notifiable, $notification)
    {
        Log::info('hola');
        Log::info($notifiable);
        Log::info($notification);
        return (new WebPushMessage)
            ->title('Approved!')
            ->body('Your account was approved!');
    }
  • Do you know why is not called?
  • Did I miss some step?

Thanks

Not really compatible with MySQL 5.6

Hello,

Your package works quite nicely on my local machine...

I do understand this is not a bug and probably using a newer MySQL version or PostgreSQL would fix things automatically. Because it works fine on latest MariaDB on my PC

I have been using your package in my project. However my host only supports MySQL 5.6 which does not support such long columns to index.

file: webpush/migrations/create_push_subscriptions_table.php.stub
code: $table->string('endpoint', 500)->unique();

Probably using another column of endpoint hashes (say sha1s of endpoint value) would be faster to search (I'm thinking of shorter strings to index, not whole URLs) and also widely compatible with databases.

(I wonder also - what DB/version have you been using when developing this package? Just curious.)

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.