Twilio messagin not receiving incomming message callback - symfony

I use Symfony 5, ApiPlatform and Twilio
My goal is to send a message to a client, then get his answer through a webhook and store it.
So I've open my route through ngrok
ngrok http -host-header=rewrite localhost:{{port}}
And setup my twilio message settings like this :
And implemented a function to send a sms :
$client = new Client($sid, $authtoken);
$client->messages->create(
'myNumber',
array(
'from' => '+twilioNumber',
'body' => $message,
'statusCallback' => "https://a7c6f2ea3843.ngrok.io/twilio/response",
'statusCallbackMethod' => 'POST',
)
);
when I send a message, I receive a callback on this my webhook /twilio/response with the status sent and delivered.
But I never receive the callback w the content of the sms I sent to twilio in reponse of the one I received
Do I miss some configuration? Or am i missing something? Thanks for your help

For anyone who would run into this kind of problem, it was an error of configuration.
On twilio console of your number you can find a link Modify the Messaging Service configuration just above the webhooks
I needed to click on it and configure it to receive the incoming messages and enter the webhook I needed to recover data when one was received.
The webhook I had configured as shown above only send data to confirm that an sms had been send and received from twilio to your client.

Related

iOS app stops receiving notifications when reconnected to internet

I have a weird problem, I send notifications via FCM to topics in iOS devices.
Sometimes when the device is connected to slow internet or no internet, and then connects back to the internet, all notification sent prior are not received, and new sent notifications after will be delayed!
For example: A device would be connected back to internet all is fine but I receive the notification delayed 10min and when I receive it the very first moment it's shown, it will say in the dialog: 10min ago!
If I restart the iPhone after that, everything will be fixed again! and I can receive notifications normally.
This issue happened to me in two different devices so I am sure its not from the phone. and other apps notifications would be working without problem as well.
I am thinking maybe its something wrong with my fcm notification configurations that I send from the server, can anyone point if I am missing something here.
Message configuration:
$message = CloudMessage::fromArray([
"condition" => $the_conditions,
"notification" => [
"title" => $title,
"body" => $body,
],
"data" => $data_passed,
//Apple:
"apns" => [
"headers" => [
"apns-priority" => "10",
],
"payload" => [
"aps" => [
"alert" => [
"title" => $title,
"body" => $body,
],
"sound" => $sound,
"thread-id" => "thread_$item_id"
],
],
],
]);
I require high availability notifications that need to be sent immediately.
Note: I am using a php library to send the notification from server: kreait/firebase-php
I'm the maintainer of the SDK you're using šŸ‘‹
Firstly, the message you composed is perfectly fine, there's nothing wrong with it.
In the context of the SDK I regularly receive issue reports about FCM messages being delivered with big delays or not at all, and unfortunately, there's no way to check if and when a message has been delivered from an Admin SDK. If you send a message to Firebase and Firebase doesn't respond with an error (e.g. when the payload is invalid, when a device token is not registered or when the server is unavailable), we have to assume that the delivery was successful.
To ensure highly reliable messages I currently see two ways how you could achieve that:
Use another messaging service that promises highly reliable delivery like e.g https://pushy.me/ (this is not a recommendation, I'm not affiliated to Pushy and have never used it)
When sending a message from your backend server, include a transaction ID in the data payload, and store it in a database. From the receiving client, issue a request back to your backend server to confirm the message reception. This way you could see if and when a message has been confirmed and can re-send it after a defined amount of time. This has some drawbacks of course - perhaps the client received the message, but the confirmation call failed, or messages could still be sent twice. It's just a naive idea from the top of my head šŸ˜…

Webhook limitations in linkedin API (webhook is not receiving updates)

LinkedIN has recently released support for webhooks and we are successful in creating a webhook url. We are able to authorise a user administrator of a company to our app and get permissions to write and read from the REST API.
However we are not receiving any webhook updates from the app for that company. And there is no documentation on how to subscribe to a particular company like in other social-media API:s witch we have vast experience from (fb,IG,Twitter).
The documentation on LinkedIn is very limited on the subject. And we are not sure what we can expect from the webhook requests from linkedIn. What is the reason we are not getting Webhooks for that company?
We dont even get webhook calls for the organisation owning the app.
Any help appreciated.
https://learn.microsoft.com/en-us/linkedin/shared/api-guide/webhook-validation?context=linkedin/context
I figure it out I need to add header json to output for validation.
Here is my code in php
if (isset($_REQUEST['challengeCode'])) {
header('Content-Type: application/json');
echo json_encode([
'challengeCode' => $_REQUEST['challengeCode'],
'challengeResponse' => hash_hmac('sha256', $_REQUEST['challengeCode'], 'client secret'),
]);
exit;
}
and for webhook subscription
$api->setApiHeaders([
'X-Restli-Protocol-Version' => '2.0.0',
]);
$developerUrn = urlencode("urn:li:developerApplication:developerid");
$personUrn = urlencode("urn:li:person:personid");
$orgUrn = urlencode(""urn:li:organization:pageid");
$endpoint = "(developerApplication:$developerUrn,user:$personUrn,entity:$orgUrn,eventType:ORGANIZATION_SOCIAL_ACTION_NOTIFICATIONS)";
$api->api("eventSubscriptions/$endpoint", ['webhook' => "WEBHOOK_URL"], 'PUT');
Webhooks are a closed beta feature at this time:
Who can use this: Any developer using a webhooks API (currently available only for social action notifications on company posts to beta partners)
Source: https://learn.microsoft.com/en-us/linkedin/marketing/integrations/recent-changes

FCM notification reply to server

There is a push notification service that sends a message from a web server to an app device. The app has onMessageReceived() method implemented. However, not all the messages are being delivered and I have read somewhere that the delivery_receipt_request field, when set to true then (FCM), replies to the server mentioning the message being either delivered or not. I want to know that how can I catch that reply from the app if the message is delivered to my sender's side code.
Option 1: Via XMPP
You need to run an XMPP client on your backend. This client should connect to FCM with your project parameters. You will then be able to process message delivery stanzas sent to you by FCM. Here are the baby steps:
Follow the steps in https://www.npmjs.com/package/node-xcs to setup the XMPP client, exporting environmental variables with your FCM project parameters.
You can send messages through there.
Listen for message delivery stanzas:
client.on('stanza', function(stanza) {
//HERE IS WHERE YOU PROCESS THE STANZA
console.log('Please process me. I AM, the stanza: ', stanza.toString())
})
The stanza you will get for message delivery will look like this:
<message id="">
<gcm xmlns="google:mobile:data">
{
"category":"com.example.yourapp", // to know which app sent it
"data":
{
ā€œmessage_status":"MESSAGE_SENT_TO_DEVICE",
ā€œoriginal_message_idā€:ā€m-1366082849205ā€
ā€œdevice_registration_idā€: ā€œREGISTRATION_IDā€
},
"message_id":"dr2:m-1366082849205",
"message_type":"receipt",
"from":"gcm.googleapis.com"
}
</gcm>
</message>
Currently only CCS (XMPP) supports upstream messaging. Knock yourself out.
Option 2: Via HTTP
Now, if you decide to use the FCM HTTP protocol instead to send the messages, then you will have to interpret the response that you get back when you make the HTTP call. You can tell whether the message was delivered or not by looking at the HTTP response header and the error in the body of the response. The structure of the response is described here: https://firebase.google.com/docs/cloud-messaging/http-server-ref#interpret-downstream
Again, knock yourself out.

Storekit - Configure a subscription status URL using Firebase functions

I'm trying to use Firebase functions as our server. Here's the function I'm using. It works fine when I trigger it over HTTP
exports.subscriptions = functions.https.onRequest((request, response) => {
// Send 200 code to the server indicate to that you are done!
response.send(200);
});
Apple Says:
The App Store will deliver JSON objects via an HTTP POST to your
server for the key subscription
But so far I didn't get any notification from Apple server.
Any suggestions would be great?
I checked the logs in the console and it seems that I have started receiving notifications from Apple server.
well you're only saying to apple that you're done, if you add console.log(req.body) to your function it should give you some data in the logs :)

Use AWS SNS to send different messages to 10000 users?

I have 10000 users, and i want to push notification SNS to each user, with different message.
So, i cannot use Topic in this case.
The problem is it delay too much. (About 1h30 hour for this to complete)
Any solution?
Thank you so much!
Endpoint is something like internal AWS Identificator for combination: platform+device token or smth else. When we want to send an message we use it as address point instead of real.
About adding Endpoint to SNS. Generally it looks like so:
You should register your platform in AWS SNS and receive e.g. for IOS - iOS app's Application ARN. It can be done via e.g. AWS Web Console
After you should create for each target user its endpoint with method like this:
$endPoint = $snsClient->createPlatformEndpoint([
'PlatformApplicationArn' => $SNS_APP_ARN,
'Token' => 'phone token'
]);
phone token for push notification is device-token. Endpoint generally is array/object which contains EndpointArn. Use it address when send message.
After that you can send an message to specific endpoint.
$snsClient->publish(
array(
'Message' => $pushMessage,
'TargetArn' => $endpointArn
));

Resources