Sending push notification to Tizen server wierd error - push-notification

I have a strange error while trying to send push notifications to watches using tizen REST API.
I did an application to carry customer's SOS (inside nightclubs) and directly push it into watches.
The strange thing is that while I send push to dev apps the RQM server dosn't have a gateway link.
But on my prod watches I have to use the server "53" that contains a gateway part.
$idToUrlMap = [
"00" => "https://useast.push.samsungosp.com:8090/spp/pns/api/push",
"02" => "https://apsoutheast.push.samsungosp.com:8090/spp/pns/api/push",
"03" => "https://euwest.push.samsungosp.com:8090/spp/pns/api/push",
"04" => "https://apnortheast.push.samsungosp.com:8090/spp/pns/api/push",
"05" => "https://apkorea.push.samsungosp.com:8090/spp/pns/api/push",
"06" => "https://apchina.push.samsungosp.com.cn:8090/spp/pns/api/push",
"50" => "https://useast.gateway.push.samsungosp.com:8090/spp/pns/api/push",
"52" => "https://apsoutheast.gateway.push.samsungosp.com:8090/spp/pns/api/push",
"53" => "https://euwest.gateway.push.samsungosp.com:8090/spp/pns/api/push",
"54" => "https://apnortheast.gateway.push.samsungosp.com:8090/spp/pns/api/push",
"55" => "https://apkorea.gateway.push.samsungosp.com:8090/spp/pns/api/push",
"56" => "https://apchina.gateway.push.samsungosp.com.cn:8090/spp/pns/api/push"
];
When I trying to send a push to any link that contains "gateway", I get this error :
{"results":[{"regID":"","requestID":"","statusCode":1011,"statusMsg":"INVALID_REQUIRED_FIELD"}]}
But when I send to other servers that does not contain gateway I just get the error I have to (for example : {"results":[{"regID":"blabla","requestID":"0000002","statusCode":3067,"statusMsg":"error of invalid serverId of regId"}]})
And all of my current 5 watches that I added are on the "53" server that contains a gateway.
Does anyone already have this problem ? Or has a suggestion ?
Thank you !

The request manager (RQM) servers collect your push notifications before sending them to the applications. The RQM server must be chosen based on the first 2 digits of the registration ID.
For example, if the registration ID of the application that you want to send a notification to begins with 04, the URL of the RQM server must be https://apnortheast.push.samsungosp.com:8090/spp/pns/api/push.
so please choose RQM server accordingly.

Related

Twilio messagin not receiving incomming message callback

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.

Oracle APEX call Dialogflow V2 in PL/SQL - Authentication with OAuth2 or Google Service Account

Migrating from Dialogflow V1 means that embedding the API key inside of client-side javascript no longer works. Instead, authentication is required with a Google Service Account (or OAuth works too? Still unclear on this).
Since the chatbot is on Blogger, there is no easy way to add server side code which would use the Google Cloud SDKs to authenticate.
So, the requests need to be routed through our Oracle APEX server, which needs to authenticate itself with Dialogflow. However, I am having difficulties with the following procedures:
https://docs.oracle.com/database/apex-5.1/AEAPI/OAUTH_AUTHENTICATE-Function.htm
https://docs.oracle.com/database/apex-18.1/AEAPI/MAKE_REST_REQUEST-Function.htm
oauth_authenticate fails with the error
s_internal_error: true
apex_error_code: APEX.REGION.UNHANDLED_ERROR
ora_sqlcode: -20001
ora_sqlerrm: ORA-20001: Authentication failed. ORA-06512
Here is the overall code:
create or replace procedure "TEST_DIALOGFLOW"
is
begin
begin DECLARE
l_response_clob CLOB;
l_rest_url VARCHAR2(1000);
l_token_url VARCHAR2(1000);
l_count_posted PLS_INTEGER;
BEGIN
l_rest_url := 'https://dialogflow.googleapis.com/v2/projects/<project>/agent/sessions/0:detectIntent';
l_token_url := 'https://accounts.google.com/o/oauth2/token';
apex_web_service.oauth_authenticate(
p_client_id => <client id>,
p_client_secret => <client secret>,
p_token_url => l_token_url,
p_wallet_path => <wallet path>,
p_wallet_pwd => <wallet password>
);
l_response_clob := apex_web_service.make_rest_request(
p_url => l_rest_url,
p_http_method => 'POST',
p_scheme => 'OAUTH_CLIENT_CRED',
p_body => '{"queryInput":{"text":{"text":"test","languageCode":"en"}}}',
p_wallet_path => <wallet path>,
p_wallet_pwd => <wallet password>
);
htp.p('HTTP Status Code: '||apex_web_service.g_status_code);
IF apex_web_service.g_status_code = 200 THEN
apex_json.parse(p_source => l_response_clob, p_strict => true);
END IF;
END;
end;
end;
I suspect that the token URL is incorrect. Or that there is a simpler way to handle this.
I also have a suspicion about the OAuth setup inside of GCloud. Do these have to be filled out?
Also, I am unclear on a Google Service Account vs. OAuth. Right now, the setup is for an OAuth key I made for Dialogflow. However, the recommended is with a service account, but I am unsure how to use the above procedures to login with those credentials.
You will need to use OAuth if you want to access the user data for the application, such as user watch time on YouTube.
By reading your code and comment, if I am not mistaken, you are implementing the chatbot on Google Blogger, right? If this is the case, you can code PHP to simplify the procedure. You can embed <iframe> and link to your own server, your server side code can be done in your server. I hope this helps.

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

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