# Troubles with Push Notifications setup

**URL:** https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993
**Category:** Support
**Created:** [February 26, 2017, 7:39pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993 "2017-02-26T19:39:17Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [February 26, 2017, 7:39pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/1 "2017-02-26T19:39:17Z")

</div>

I’m trying to get Push Notifications to work but having some issues.

I have pretty standard setup and tried to follow the manual:  
[https://meta.discourse.org/t/discourse-push-notifications/46692](https://meta.discourse.org/t/discourse-push-notifications/46692)

- installed plugin [discourse-push-notifications](https://github.com/discourse/discourse-push-notifications)
- setup SSL via Let’s Encrypt
- created an app in Google Cloud with GCM API
- setup credentials
- set api key and project id in plugin settings

When I reloaded my app in Chrome on Android, Chrome suggested to add site onto home screen (as an app). But no question on push notifications was asked. So they don’t work.

In Google cloud console I can’t see any traffic for GCM.

What to check? How to debug? Any help is appreciated.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 26, 2017, 9:14pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/2 "2017-02-26T21:14:11Z")

</div>

To get notifications you must go to your profile and click the **Enable Push Notifications** button.

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [February 26, 2017, 9:23pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/3 "2017-02-26T21:23:38Z")

</div>

Ok, found it and enabled. But still there’re no notifications…

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 15, 2017, 9:30am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/5 "2017-03-15T09:30:07Z")

</div>

I have to dump the topic up and tried to ask advice one more time as I really have no idea what to check more.  
So I’d narrow the question to: how to check that Discourse **tries** to send any push notifications?

I setup GCM but I can’t see any incoming activity in its stats, so problems is obvious on my server side, “push notifications” were activated in user settins, tried different browsers (push notifications work fine for meta.discource for me, so the problem is not with the browser/device)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 15, 2017, 9:48am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/6 "2017-03-15T09:48:01Z")

</div>

Can you try the following steps?

1. Enable push notifications for your user
2. Run this command from your `rails console`: `DiscoursePushNotifications::GCMPusher.push(User.find_by(username: '<your username>'), {})`

You should receive a push notification almost immediately. If not, it’ll indicate that the configurations for google cloud messaging might be incorrect.

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 15, 2017, 10:51am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/7 "2017-03-15T10:51:00Z")

</div>

> [@tgxworld](#):
>
> DiscoursePushNotifications::GCMPusher.push(User.find\_by(username: ‘\<your username\>’), {})

I got `nil` and no notifications:

```plaintext
[7] pry(main)> DiscoursePushNotifications::GCMPusher.push(User.find_by(username: 'Shrike'), {}) => nil

```

So, something wrong is with my GCM settings… Is there some logs somewhere? I checked:

```
/shared/log/rails/production.log 
production_errors.log
unicorn.stdout.log
unicorn.stderr.log

```

but there’s nothing there

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 15, 2017, 11:28am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/8 "2017-03-15T11:28:12Z")

</div>

Hmm maybe try going through the setup GCM again? Is Firefox push notification working for you?

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 15, 2017, 11:38am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/9 "2017-03-15T11:38:19Z")

</div>

> [@tgxworld](#):
>
> Hmm maybe try going through the setup GCM again?

Done this several times

Found this interesting warning in [GCM docs](https://developers.google.com/cloud-messaging/gcm):

 ![](https://global.discourse-cdn.com/meta/original/3X/f/8/f8a45d2db0a1a147cea37ed2ad6eaa66428a229d.png)  
So I migrated my GCM project to Firebase, and tried using new server key (longer)  
([https://console.firebase.google.com/project/](https://console.firebase.google.com/project/)/settings/cloudmessaging)  
But it changed nothing.

> [@tgxworld](#):
>
> Is Firefox push notification working for you?

No (  
(tried two accounts and desktop and Android)

Right after I recreated GCM app and re-run the code I got some different result:

```plaintext
[8] pry(main)> DiscoursePushNotifications::GCMPusher.push(User.find_by(username: 'Shrike'), {})
=> {"discourse_push_notifications"=>{"google-cloud-messaging"=>{}, "push-services-mozilla"=>{}}}

```

(instead of `nil`)  
But still there’re no notifications.  
Next run returned again `nil`.

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 15, 2017, 12:52pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/10 "2017-03-15T12:52:23Z")

</div>

Are there any subscriptions in

`User.find_by(username: <user>'').custom_fields`

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 15, 2017, 12:54pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/11 "2017-03-15T12:54:33Z")

</div>

> [@tgxworld](#):
>
> Are there any subscriptions in
> 
> User.find\_by(username: ‘’).custom\_fields

Yeah:

```plaintext
[1] pry(main)> User.find_by(username: 'Shrike').custom_fields
=> {"discourse_push_notifications"=>{"google-cloud-messaging"=>{}, "push-services-mozilla"=>{}}}

```

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 16, 2017, 12:48am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/12 "2017-03-16T00:48:45Z")

</div>

Finally I got it working!

I came into GCM again and noticed that now I have not only API key but also Server Key.  
**Probably** it’s after I migrated my app to Firebase.  
I used the server key and finally it starts working.  
So the [manual](https://meta.discourse.org/t/discourse-push-notifications/46692) is outdated and the warning in the docs makes sense. For push notifications to work we need server key which cannot be created in [https://console.developers.google.com/apis/](https://console.developers.google.com/apis/) anymore.  
Instead we have to use [https://console.firebase.google.com/](https://console.firebase.google.com/)

 ![](https://global.discourse-cdn.com/meta/original/3X/1/3/13e0b0ea35a13dff16fb4abedf636d0652124e47.png)

BTW: there’re two server keys there: long (“Server key”) and short (“legacy server key”). For GCM we need the legacy one.  
(I previously tried the long one)

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 16, 2017, 12:49am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/13 "2017-03-16T00:49:58Z")

</div>

Ah ha. Let me update the docs soon 🙂 Thanks for debugging this!

Hmm still Mozilla push notification should work automagically.

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 16, 2017, 10:57am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/15 "2017-03-16T10:57:05Z")

</div>

> [@tgxworld](#):
>
> still Mozilla push notification should work automagically.

maybe, but for me they don’t.

also after some time of celebrating it stops working again ☹ All I did as I can remember - edited credentials (restrictions/name), rolling back, creating new credentials (in Firebase) and a new project in Firebase didn’t help.

---

<div class="post-metadata">

### Author: ![frostydog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frostydog/32/68228_2.png) [@frostydog](https://meta.discourse.org/u/frostydog)
#### Post date: [March 24, 2017, 10:57pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/16 "2017-03-24T22:57:45Z")

</div>

For several days I’ve been trying to make the plugin work without success. I’ve followed the very outdated guide, then I’ve discovered exactly what @Shrike found out. But it just doesn’t work.

I’ve tried creating a new project, but that is not helping either.

I deleted everything, uninstalled the plugin, re-installed it again, nothing.

Even though the settings are correct (Organization ID + legacy server key entered in settings) I get the following error in the console when pressing the push notifications button on my profile:

`Registration failed - missing applicationServerKey, and manifest empty or missing`

Also, button dissapeared on Firefox browsers ¯\_(ツ)\_/¯

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 25, 2017, 5:43am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/17 "2017-03-25T05:43:24Z")

</div>

Can you try upgrading again? I just pushed a new version of Discobot that wouldn’t require you to register an app with Google at all.

[https://github.com/discourse/discourse-push-notifications/commit/db8d0d03345274a1af270d4b015a444f15a37a9d](https://github.com/discourse/discourse-push-notifications/commit/db8d0d03345274a1af270d4b015a444f15a37a9d)

---

<div class="post-metadata">

### Author: ![frostydog](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/frostydog/32/68228_2.png) [@frostydog](https://meta.discourse.org/u/frostydog)
#### Post date: [March 26, 2017, 4:40pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/18 "2017-03-26T16:40:37Z")

</div>

Now it works like a charm. Thank you!!

---

<div class="post-metadata">

### Author: ![Shrike](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shrike/32/68103_2.png) [@Shrike](https://meta.discourse.org/u/Shrike)
#### Post date: [March 26, 2017, 4:42pm UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/19 "2017-03-26T16:42:06Z")

</div>

It works for me on desktop and mobile (Chrome & Firefox). Thanks a lot!

---

<div class="post-metadata">

### Author: ![tgxworld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgxworld/32/106117_2.png) [@tgxworld](https://meta.discourse.org/u/tgxworld)
#### Post date: [March 27, 2017, 9:35am UTC](https://meta.discourse.org/t/troubles-with-push-notifications-setup/57993/20 "2017-03-27T09:35:24Z")

</div>


