I am working on a project that notifies an android application using push notifications using Google Cloud Messaging. I have implemented the application server in PHP. When i run the android application, the device gets the registration id from the GCM server and it sends the registration id to the PHP server(application server). But i get the following httpresponse from the server :
{
"multicast_id": 7015234441922271670,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [{
"message_id": "0:1344007383866721%2adac3a0ad8b3148"
}]
}
So, the message is getting delivered since the success flag is 1, but when i display the message in the android app, it displays nothing(null). I am not able to figure out what happens with the message.
I have the exact same question ... this is what i'm trying this weekend:
http://developer.android.com/guide/google/gcm/gcm.html
excerpt:
Note: If your organization has a firewall that restricts the traffic to or from the Internet, you'll need to configure it to allow connectivity with GCM. The ports to open are: 5228, 5229, and 5230. GCM typically only uses 5228, but it sometimes uses 5229 and 5230. GCM doesn't provide specific IPs. It changes IPs frequently. We recommend against using ACLs but if you must use them, take a broad approach such as the method suggested in this support link.
Add this in your php code
$data = array(
'registration_ids' => array($reg),
'data' => array(
'type' => 'New',
'title' => 'App Name',
'flag' => '1',
'msg' => 'New Message')
Hope this will help.
Related
I want to make a call from a web application(PHP/Laravel) to any mobile number from (purchased Nexmo Number). It's like a two-way communications call.
The scenario assumes in the web application(PHP/Laravel) page display the call driver options placed the call icon. Once customers click the call icon then call to driver number from (purchased Nexmo Number).
I have used this API to create a call.
$ncco = [
[
'action' => 'talk',
'voiceName' => 'Joey',
'text' => 'This is a text-to-speech test message.'
]
];
$call = new \Nexmo\Call\Call();
$call->setTo('XXXXXXXXXXXX')
->setFrom('XXXXXXXXXXXX')
->setNcco($ncco);
$response = $client->calls()->create($call);
echo $response->getId();
The Nexmo Voice API here one-way communication only working fine for me. For example, text to speech call works for me, the above voice API code run the call automatically reached to destination number from (purchased Nexmo Number).
Is anybody has done this scenario? when you click on the phone icon it will call customers + you can talk with customer using a web portal?
There are two ways to go about this.
Call Bridging
You can bridge two numbers together by having the system call you, and if you answer then call someone else to bridge them in. This can all be done on the server side much like what you have above, the NCCO just changes slightly.
$ncco = [
[
'action' => 'connect',
'endpoint' => [
[
'type' => 'phone',
'number' => DRIVER_NUMBER
]
]
]
];
$call = new \Nexmo\Call\Call();
$call->setTo(CUSTOMER_NUMBER)
->setFrom(VONAGE_NUMBER)
->setNcco($ncco);
$response = $client->calls()->create($call);
echo $response->getId();
The only real problem with this is the user experience. The user probably expects the call work like a real phone call (click the button, hear ringing, hope the driver connects). You would need to add some additional NCCO options like streaming a ring tone, checking to see if the other person declines the call or never answers and responding appropriately, etc, but it can be done by pushing some NCCOs around and watching the voice events.
In Browser/In App
The other option is our Client SDK, which is available for front-end JavaScript, iOS, and Android. This can be used to place a call from a browser or app, and do functionally the same but from within a dedicated interface. A short tutorial can be found at https://developer.nexmo.com/client-sdk/tutorials/app-to-phone/introduction/javascript.
As per the official document, we can send push notification to multiple devices using a topic or device group. But the problem is it needs a common message and payload data for all devices.
I want to send different messages to all devices.
For example, below users should receive the following message on their
devices.
User Amit: Hello Amit, your request approved.
User Sandip: Hello Sandip, your request declined.
User Piyush: Hello Piyush, your request declined.
And so on..... to 200-300 users.
Is it possible to send this all messages in a single HTTP request using Firebase Cloud Messaging?
It is possible with the official Admin SDKs (see https://firebase.google.com/docs/cloud-messaging/send-message#send_a_batch_of_messages), but unfortunately, the REST API documentation doesn't include information on how to send batch requests (yet, at least I didn't find them so far), probably because it involves creating a special kind of multipart request and is not easy to set up.
So I would advise using an Admin SDK to do it. As I don't know how you've sent the messages in the past, please be warned that using an Admin SDK comes with some additional setup (e.g. creating/downloading a Service Account), compared to making "just" a cURL request.
So, if you don't have to use PHP, it's always wiser to use one of the official SDKs (see https://firebase.google.com/docs/admin/setup/)
If you do choose to stick with PHP, there is an unofficial Admin SDK for PHP at https://github.com/kreait/firebase-php that supports sending batch messages. (Disclaimer: I'm the maintainer of that SDK).
You can read more about it in the repo or specifically at https://firebase-php.readthedocs.io/en/latest/cloud-messaging.html#send-multiple-messages-at-once, but here is how it might look like for your situation if you decided to give the PHP SDK a try:
use Kreait\Firebase\Factory;
use Kreait\Firebase\Messaging\CloudMessage;
use Kreait\Firebase\Messaging\Notification;
use Kreait\Firebase\ServiceAccount;
$serviceAccount = ServiceAccount::fromJsonFile('/path/to/service_account.json');
$users = [
['name' => 'Amit', 'is_approved' => true, 'registration_token' => '...'],
['name' => 'Sandip', 'is_approved' => false, 'registration_token' => '...'],
['name' => 'Piyush', 'is_approved' => true, 'registration_token' => '...'],
// ...
];
$messages = [];
foreach ($users as $user) {
$statusText = $user['is_approved'] ? 'approved' : 'denied';
$messages[] = CloudMessage::withTarget('token', $user['registration_token'])
->withNotification([
'title' => "Your request was {$statusText}",
'body' => "Hello {$user['name']}! Your request was {$statusText}.",
]);
}
$messaging = (new Factory())
->withServiceAccount($serviceAccount)
->createMessaging();
$sendReport = $messaging->sendAll($messages);
echo 'Successful sends: '.$sendReport->successes()->count().PHP_EOL;
echo 'Failed sends: '.$sendReport->failures()->count().PHP_EOL;
I hope this helps!
I am using this to send push notification to iOS and it is working fine except the fact that I don't know how to send a silent push using this package. I have tried to send it like this:
$payload = PushNotification::Message('', array(
'aps' => array(
'content_available' => 1,
),
'data' => array(
'actionType' => $actionType
)
));
Sending empty string in the first param of ::Message, it does not show anything on mobile screen but it does produces the sound. Secondly, I tried it without the presence of this param. But if this param is not present, it throws exception. How to send silent push? Any ideas?
My Laravel version is 5.4.
Such a trivial mistake that I made in the code shown above in the question is to use content_available instead of content-available.
I'm trying to receive e-mails sended to my account on sendgrid.
So What I basically have is the following:
A sendgrid account linked to http://www.rallypodium.be
A cloudflare account linked to http://www.rallypodium.be server IP adress.
A server on DigitalOcean.
Good, So I'm running Nginx on that server and I want to be able to get the e-mails send to #rallypodium.be to be saved and stored inside of my database wich is on the same DigitalOcean server.
I've set up the Inbound Parse like this:
HOST: www.rallypodium.be
URL: http://www.rallypodium.be/inbound/parse/mail
My domain is whitelabled.
I've read the docs for 10 times and still didn't figure out what I'm doing wrong.
This is how I store them:
public function ReceiveMail(Request $request)
{
DB::table('email')->insert([
'headers' => $request->get('headers'),
'html' => $request->get('html'),
'from' => $request->get('from'),
'to' => $request->get('to'),
'cc' => $request->get('cc'),
'subject' => $request->get('subject'),
'dkim' => $request->get('dkim'),
'spf' => $request->get('spf'),
'envelope' => $request->get('envelope'),
'charsets' => $request->get('charsets'),
'spam_score' => $request->get('spam_score'),
'spam_report' => $request->get('spam_report'),
'attachments' => $request->get('attachments'),
'attachment-info' => $request->get('attachment-info'),
'attachmentX' => $request->get('attachmentX')
]);
return 'ok';
}
If I take a look at the Activity Feed, then I see this:
The error message is the following:
EMAIL: robin#rallypodium.be
REASON: error dialing remote address: dial tcp 104.24.101.114:25: i/o timeout
SMTP-ID: <1f7f313f27fd051b525581562e6af9b5#rallypodium.be>
PROCESSED STRING: August 1, 2016 - 06:53:45PM
MSGID: J1irmehmR_GELI7tIpPXNg.filter0810p1mdw1.1861.579F77CC27.0
oh and this is my cloudflare DNS: http://prntscr.com/c0bjl8
Can someone help me out?
Thanks!
You are essentially trying to receive email through CloudFlare, but unfortunately CloudFlare doesn't proxy SMTP/email traffic.
Instead you'll need to add a grey-clouded record to manage your email, this will allow your email to be routed straight to your origin without CloudFlare blocking it. Note that grey clouded domains can reveal your IP Address, it is therefore recommended to have your email server on a separate server to your webserver; or even better use a Cloud email provider and get emails from them.
I have a flash based ios app that I am currently testing on phone/ipod.
I have added push notification to the app and I am receiving device tokens from apple.
I have added those tokens to AWS SNS APN SandBox
The platform Application ARN looks like
arn:aws:sns:us-east-1:7860818154325:app/APNS_SANDBOX/gamename
I have added tokens to the PAA and they look like:
token: f63d05538cd7d9b86c76188dbfeb42edf26a1e23b47334a02a205e0fb54a812a
endpoint ARN: arn:aws:sns:us-east-1:7860818154325:endpoint/APNS_SANDBOX/gamename/7412740a-79e4-3b71-8e7f-56e127bc4cg1
Sending out the notification via PHP:
require 'vendor/autoload.php';
$sns = Aws\Sns\SnsClient::factory(array(
'key' => 'mykey',
'secret' => 'mysecret',
'region' => 'us-east-1'
));
$snsmessage = $sns->publish(array(
'TargetArn' => "$endpoint",
'Message' => 'A game is waiting for you to play'
));
(where $endpoint = "arn:aws:sns:us-east-1:7860818154325:endpoint/APNS_SANDBOX/gamename/7412740a-79e4-3b71-8e7f-56e127bc4cg1")
$snsmessage returns a message ID, so it looks like it is sending the message.
However no message is ever received on the phone.
I have tried manually sending a message from the SNS portal and the same issue. IT sends with no error message but it never arrives.
I am building the app as "device testing" and I am using provisionprofile that has push notifcation enabled.
I am not sure where to start looking to find the issue.
Any help would be appreciated.