I'm using EasyAPNS as PHP server script to send Push Notifications to iOS devices.
It worked perfectly in development using Apple Development Push Notifications Certificate, but when switched to Distribution it set the message as "delivered" but never received on iOS devices downloaded from App Store!
I have tested Apple Distribution Push Notifications Certificate along with my app downloaded from the App Store using this Script and it worked perfectly! So the problem is not from my distribution certificate nor from my app, it's somewhere in EasyAPNS scripts and settings but I have no idea where is it and how to fix it!
Check if your using the right servers.
In your testing using that script, was development set to false? Or true depending on which example your using. Check if either of these result in the correct use of the production server.
$development = true; // boolean
I found the bloody reason :)
The payload in apns_messages.message column was not inserted as a complete payload format due to a long message used, so the content of the message field was like the below:
{"aps":{"alert":"\u064a\u0627 \u0639\u0644\u064a \u0623\u0646\u062a \u0627\u0644\u0648\u0644\u064a \u064a\u0627 \u0639\u0644\u064a \u0623\u0646\u062a \u0627\u0644\u0648\u0644\u064a \u064a\u0627 \u0639\u0644\u064a \u0623\u0646\u062a \u0627\u0644\u0648\u064
So the change I made was to make sure use a very short message to make sure EasyAPNS insert a complete payload message format in apns_messages.message column, so the content of the field is like the below:
{"aps":{"alert":"\u064a\u0648\u062c\u062f \u0625\u0639\u0644\u0627\u0646 \u062c\u062f\u064a\u062f \u0645\u0646 \u062e\u062f\u0645\u0629 \u0628\u0644\u063a\u0646\u064a","badge":5,"sound":"alarm.caf"},"module":"messages","id":"28"}
Related
I want to send notifications to multiple android devices(where same app is installed) by fcm from php server side by calling this url -
https://fcm.googleapis.com/fcm/send
I checked sending messages to device groups but my requirement is such that there will not be definite devices to which i will send messages because i am going to do it in a hourly cron job, and each time a cron job runs it will send notification messages to different different devices according to requirements. or can it be done in another way?
But i am thinking to use "registration_ids" parameter instead of "to" parameter, details of these fields here in the Downstream HTTP messages section. In this registration_ids field i will put all required device registration tokens in array. Now my question is after receiving message in android device can the message be parsed in the android app sdk codes?. i am in a bit of doubt as in this documentation there are no mentions of registration_ids parameter when sending messages to multiple android devices. Please assure me. And furthermore, will the message be sent when android app is in background?!. Please don't write one line, provide some examples if possible.
In the documentation for building requests to send to multiple devices you will find an example of passing multiple FCM tokens in a single call to the FCM API in the tokens parameter (in Node.js) or by using a HTTP batch request with multiple subrequests (in the REST API).
If you're having a hard time making this work, posting a question that shows what you tried increases the chances that someone can help making it work.
Yes, the message is sent regardless of whether the app is in the foreground, or in background. Whether the notification is actually shown depends on many more factors, many of which are outside of your control (such as the Android version, device maker/OEM, and the user settings).
self.addEventListener('push', function(event) {
var jsonObj = event.data.json();
}
I have written chrome web push notification, but event.data is always null.
Currently I am using GCMPushMessage library, I think I need php curl for sending notification. Can anybody help me to send web push notification with payload?
As of 2015 , this related SO post stated, this is an intended behavior.
A downside to the current implementation of the Push API in Chrome is that you can't send any data with a push message. Nope, nothing. The reason for this is that in a future implementation, payload data will have to be encrypted on your server before it's sent to a push messaging endpoint. This way the endpoint, whatever push provider it is, will not be able to easily view the content of the push message. This also protects against other vulnerabilities like poor validation of HTTPS certificates and man-in-the-middle attacks between your server and the push provider. However, this encryption isn't supported yet, so in the meantime you'll need to perform a fetch to get information needed to populate a notification.
As provided by the document you have to fetch the information then populate it in the notification.
An update was released March 2016 named : Web Push Payload Encryption
Prior to Chrome 50, push messages could not contain any payload data. When the 'push' event fired in your service worker, all you knew was that the server was trying to tell you something, but not what it might be. You then had to make a follow up request to the server and obtain the details of the notification to show, which might fail in poor network conditions.
Now in Chrome 50 (and in the current version of Firefox on desktop) you can send some arbitrary data along with the push so that the client can avoid making the extra request. However, with great power comes great responsibility, so all payload data must be encrypted.
Ensure you've followed the implementation needed for applying payload in web push for Chrome. Like some Client-side changes and Server-side changes.
Hope this helps.
I am using Google Cloud Messaging from last one year with PHP as server side script and it is working fine on all app until I hasn't sent notification to one of the may application for one month then after that while sending notification to same app I gets blank response like
{"status":[],"0":"\n\n
so I assumed that google may have deactivated my API key so I regenerated my API key from developer console and replaced regenerated key with old key on server side and at that time it had worked I was able to send message again but after two week again I am getting blank response like given above and this time I was sent notification to same app everyday.
From this related SO question. It suggested to make sure that it's retrieving the POST variable in your PHP code.
Try to replace this:
$message = array("Notice" => $_POST['message']);
with:
$message = array("Notice" => "testing");
You can also check on this tutorial and thread on how to integrate GCM in PHP backend properly.
Problem is solved after importing project into firebase.
Server API Key is auto generated by google services and after using those keys on server site i am able to send notification.
I'm new to WinDev Mobile. In the project that I'm working on, there is a need for implementing Push Notification with use of GCM.
The notification will be sent from PHP script running on our web server.
For this, it is necessary that the mobile app registers with Google Cloud Messaging (GCM) . This seems to work, But I'm getting the Registration ID like this as a String type.
!‘‰åpWx£Üx½ZÌì–´äUü;jÚÿ†Pȧ#úùrjIìÑtð*æW‹1ç‰Yæµß;Ar‘ýãU»ç
I've to do this because I'm not able to send Buffer content to MySQL. For communicating between mobile app and MySQL I'm using c_PHP4WM 7.0 webservice.
In MySQL the field name is pn_reg_no and its datatype is text. Is this correct?
Try to convert that string with function StringToUTF8()
I am trying to develop a web site which will send push notifications to all users currently watching it. I found some tutorials on how to send pushes to myself using GCM for Chrome and they are working fine,
(https://github.com/gauntface/simple-push-demo)
but I cannot understand how to send pushes to every user who is currently on my site and allowed to receive them. As far as I understand I need to collect their browser IDs when they subscribe
navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
serviceWorkerRegistration.pushManager.subscribe({ userVisibleOnly: true })
.then(onPushSubscription)
but I cannot find how to get and store them (perhaps in MySQL DB with PHP code) and after that how to send a push to everyone (probably to iterate over all browsers IDs in my DB and send pushes to everyone separately with cURL requests). On my site I have code which uses ServiceWorkers and handles users subscription but everything is working for me only. Noone who is else on a site does not receive any notifications. Any help would be appreciated.