I followed the instructions in the Rocket.chat documentation:
Removed the check mark from the gateway
added GCM keys from firebase
rebooted the server
Pushs seem to come, but the listener "pushnotificationreceived" is triggered only if I open the application immediately after the push should come or I am in the application during the push, if I have minimized the application and send myself a message, then there is no push.
If I throw the push myself through the firebase API, then the push works out as needed.
There is a suspicion that this is due to the fact that Rocket.chat sends push data in the data key, not notification (https://github.com/RocketChat/Rocket.Chat/blob/develop/app/push/server/gcm.js).
I also have an error in the Rocket logs.Chat:
"For devices running Android 8.0 or later, you need to specify the android_channel_id identifier. See https://github.com/raix/push/issues/341 for more information", but even with this error, push writes that it was sent successfully.
Please, checkout this post:
https://forums.rocket.chat/t/apple-push-notification-service-update-from-legacy-binary-protocol/12425/4
Also, consider asking dev questions at:
https://open.rocket.chat/channel/dev
Do I need to open the app at least once in order for my phone to receive a push notification?
The must run at least once so it can collect a device ID token and send that to the backend that will send the message. Without that token collected, the app can never receive a message on that device.
Read more about it: What is FCM token in Firebase?
Actually you do not need the device token to send/receive the messages.
However, it is required that the user give permission to receive notifications, and that would only happen during runtime. I tested this and can confirm it works. The device token is only used to subscribe users to specific topics, but you can send a message to all users that have your app installed without needing to specify device tokens.
We have an iOS app which is able to receive push notification through the Apigee SDK.
The push notifications are sent by using the Apigee admin console.
Within the console, we configured both dev and prod environments. The prod environment is used for the app published in the App Store. In both cases, the push notifications are well received by our iPhone devices.
However, my question is about the status displayed in the Message History section of the Apigee console.
In the case of the dev notifier, the console display the message : Finished (with errors) with by example, a total sent of 660 for a total errors of 1318.
I don't well understand these figures and I don't know where they are documented.
Is the total sent figure for the number of devices to which the push is sent? However, we don't have as many devices with the dev app version installed
The devices we have with the dev app version installed have well received the push as expected so why are there as many errors?
The detail of the error message is: "INVALID_TOKEN: Failed sending notification."
Thanks very much for your help
We have a bug where statistics get calculated inaccurately if you have errors from the Apns service since they come back asynchronously.
Invalid Token usually means the device is not registered with the apple push notifications service anymore.
I am sending Push notification messages from my asp.net web site to Android and iPhone.I am using push-sharp version is 2.1.2.0-beta lib.I can send push notification messages successfully and having status log for each message along with there Device ID.
I found more that 100 device which was having DeviceSubscriptionExpired(PushSharp Event). I check those devices on my database, i found those same device id was successfully on the same day.I am suspecting that those devices are not expired but DeviceSubscriptionExpired event is fired for some reason or apple and google server responding with Subcription expired.
I can't figure it out why it is happening. Can anyone please suggest?
Note: My apps are designed such a way that it will request device id on each application start and update the latest device id if it is changed.
Maybe you are using a developer certificate, you should check you are using the production if you are sending push to production apps.
I'm trying to understand what I will need to build on my server for Push notifications to work successfully.
My thoughts were:
The phone sends the notify URL to my server
The server stores the information in a Database
A separate process or PHP script will query the database and open continuous looping process for each device. (Each socket will be querying a 3rd party API)
When there is a change detected in the API for that device a push notification will be sent to the device's notify url.
Is this the right method on what needs to be done. Isn't this going to eat up server resources or is it the expected outcome of Push a push notifications server?
I've produced a simple diagram on all this below:
First of all, let's separate the process in the main stages needed for PUSH.
Device subscription.
Send the PUSH
Process the notification on device.
Subscription
For the subscription, your device (more specifically, your App) must call the PUSH api,for enabling PUSH notifications. This call to the push API will give you a URL that uniquely identify the device where your application is installed and running. You should store this URL on your database, the same way you store a user's email, or a user's phone number. No special black magic here. You only use it when you need to send a communication to a user.
Send the PUSH
For the push stuff, the same approach as for email, or SMS messaging here: "One does not simply make an infinite loop and send a message if any change is detected". What you have to do is, just send the PUSH message when your application needs to. So you have the user to which you want to send a message, instead of opening a SMTP connection to send ane mail, just build the PUSH XML Message and call the URL associated with that user. Some things to consider here are:
Network reliability (you need to retry if you can't connect to the server).
Response error code-handling (you don't need to retry if the server tells you that the phone has uninstalled your application, for example).
Scalability. You don't want to send a PUSH message from your PHP code, because you don't know how long it will take for the task to be completed. You have to make this thing asynchronously. So just queue up all the push messages, you can create a separate process (windows service, nodeJS service, cron job, daemon, etc.) to send the PUSH, handle retries and errors and clean the queue.
Process the notification on Device
So now that you are this far, you need to handle the notification on the phone. It depends on the type of PUSH notification that you are sending:
Tile. You will update the image, text and counter of the application tile, if the user has put your application to the start screen. On client side you need nothing to so, as all these parameters are part of your PUSH request.
Toast. This one requires a title, text (limited to some 35 characters more or less) and a relative URL inside of your APP. Your application will be launched (like when you click on a Toast notification from Twitter, for example) using the URI that you specify in the payload. So a bit of data can be already injected here. You may/or may not make a request to your server for new data. It is up to you.
Raw. This one is pretty much silent. Is not seen by the user if your APP is not running. As you might guess, this kind of PUSH is useful to live update your running APP, instead of continuously polling your server, wasting user battery and bandwidth and wasting your server resources. You can send anything (raw bytes or strings) up to the max size of the payload allowed my Microsoft.
If yo have any more questions, don't hesitate to ask.
Bottom line: separate the PUSH sending, make it async, don't you ever forget that...
Your PHP script that continually pings the database for changes...THAT is what will eat up your system resources. Push notifications go hand in hand with Event Driven Programming. This means that ideally, your code shouldn't continuously ping your DB. Rather, when something happens (ie, an "event"), THEN your code does something...like contact your phone via push notification.
Your steps for push notifications are more or less correct, but are incomplete. Step 4: the server contacts the client via the notify url (which you have). Step 5 is that the client then contacts the server to actually pull down the information it needs. That is: The new information is not provided to the client via the notify url. Once the client has its new information, then the program continues as normal (populates a list, downloads skynet, etc.)
Your third step is very wasteful and not practical if your app is installed on more than a few devices.
Instead, each device should be subscribed to types of server updates it cares about. Your server's DB will have a mapping from each type of update you support to the list of notification channel URLs of devices that care about this update type.
When your server detects an update of type X, it would send a notification to all devices subscribed to that type of update.