I have set up many push notifications in iOS projects. I always receive the same message which I have sent from my application, all going well.
But when I change my server from my local machine (or a dedicated server) to web hosting the message format changes somewhat. For which we are not accepting.
Sample message from our server:
{"msg":"match found !","match_id":"34","rqst":"1"}
Sample message from web hosting server (remote server) :
{\"msg\":\"Match found !\",\"match_id\":\"34\",\"rqst\":\"1\"}
It contains extra backslashes before and after every string.
FYI we are using Slim Framework with PHP MySQL APIs, and the messages sent are JSON.
Use PHP to get ride of the slashes before sending the message.
<?php stripslashes($YourMessage); ?>
Related
I have recently begun building an Angular Ionic app which connects to PHP scripts on an AWS EC2 server. Everything works fine except for when I try to connect through Android once the app is built on my phone.
The response is a simple 404 response with no additional information. When I look at the log on Android Studio I see the following response:
E/Capacitor: Unable to open asset URL: [api address]
I have reduced both the HttpClient call on the frontend and the php file on the backend to their most simple forms and yet still nothing:
<?php
echo "Hello";
?>
I know that Capacitor was updated to 3 only a couple of months ago and am concerned that it is related to that. I am using PHP 7.
UPDATE
The issue was indeed cleartext but the issue was made more complicated by the fact that HttpClient was not catching the error and so I was simply getting back an unknown failed response.
In order to first see that it was cleartext I first had to change HttpClient for the Native HTTP plugin and check the logs whilst testing on my phone (HTTP will not work through the browser).
Only then did I notice that I hadn't changed the config file correctly.
As long as your PHP web server is not running on the Android device directly trying to connect to localhost / 127.0.0.1 won't work and you need to use another domain / IP your web server is available on and which the Android device can access. You can also check this by simply opening the URL in the browser of the Android device.
If that is not feasible for you you could also use port forwarding via adb to forward a port of your web server to a local port on the Android device.
If you use another domain / IP make sure your web server is not listening to local connections only and is not blocked by a firewall or similar.
Also if you are using an unencrypted connection (i.e. http instead of https) you might need to enable the cleartext config option in you Capacitor config.
We have a web server running Yii2 (PHP) and are trying to send push notifications using the aksafan/yii2-fcm-both-api https://packagist.org/packages/aksafan/yii2-fcm-both-api
Sending push notifications works fine locally, so it's not a programming issue, but on the staging server in the corporate environment the push notifications aren't working. The sending fails because some of the Firebase domains are being firewalled.
We sent the Network Engineers the information about firewalling https://firebase.google.com/docs/cloud-messaging/concept-options#ports_and_your_firewall
All IP addresses contained in the IP blocks listed in Google's ASN of 15169. Don't forget to update this at least once a month.
But they can't do that. We then asked them to allow *.googleapis.com
Unfortunately their response is:
We need a list of the Fully Qualified Domain Names as a wildcard firewall rule is not possible.
The FQDN must begin and end with a digit or letter. Only letters, digits, and hyphens are allowed as internal characters.
Reference:
http://www.cisco.com/c/en/us/td/docs/security/asa/asa-command-reference/A-H/cmdref1/f2.html#pgfId-2058089
We've asked them to enable fcm.googleapis.com and after lots of debugging discovered connection issues trying to call oauth2.googleapis.com
So the question is:
What is the list of Fully Qualified Domain Names needed in order to send (no need to receive) Firebase Push Notifications (FCM) using the v1 API?
FCM send msg through firewall using firebase-admin library wasn't nearly exhuastive enough.
The current list I've got which it could possibly be includes:
iid.googleapis.com
fcm.googleapis.com
www.googleapis.com
oauth2.googleapis.com
accounts.google.com
identitytoolkit.googleapis.com
Are there ones we are missing? Are there ones on there we don't need?
Thank you
I have a working chat server in Php/Ratchet. I am using Starscream as my client in Swift. I successfully created a chat between users however this only works when my application is open because this is when the socket is open. How do I make my app receive messages even if my app isn't on. So basically is there a way to keep sockets open. I read somewhere that it is forbidden by Apple.
There's a high probability that your process is going to be shutdown by the system at some point, so I wouldn't rely on the app being active in the background.
Try coming up with a solution for receiving past messages when the client becomes online.
Read about Apple Push Notification Service to notify your users about messages while the app is not active.
Sounds like you are sending messages from your client to your phone. You need to send messages to a server and the server sends them to your phone.
The server, if unable to successfully send a message to your phone, should store the message and should send the stored messages to the phone when the phone is available.
There are message queuing systems for things like this. See, for example, RabbitMQ. There are loads of others too that may work better with your tech stack. Do some research.
Here the client talks to the server, the server hooks up with RabbitMQ or whatever you choose to use, RabbitMQ keeps a track of queued messages and when the phone comes online, RabbitMQ sends the queued messages to the server and the server sends them to the phone.
PS Google "message queue PHP".
You need to be in sync with server. Do following steps.
Dump every message in Database i.e. conversation from both parties with timestamp.
When app goes in to background and comes to foreground flush your all messages which are on your screen/local array for showing messages on screen, call a Sync service which will fetch whole conversation, because definitely server will be having all messages, feed you screen with this service response.
The iOS system will receive socket calls at kernel level but will not pass those messages to you app, so you will not get messages while app is in background.
When app is killed you can implement APNS from apple.
This question already has answers here:
Receive SMS messages in a web application in the US on a hosted server
(5 answers)
Closed 8 years ago.
I will be setting up a website hosted on GoDaddy in the near future. However, one of the key components to making this website work is it's reliance on text messages coming from my phone. I will use SMS messaging to text my server with specific updates (example: "on route," "no longer delivering," etc). The idea is I text a specific address and the server updates a text file with the specific information from the text message from my phone. Then, when someone goes to the website, it will pull data from the text file to determine the current status and act from there.
How would I set up such a service through a web hosting server? I am familiar with HTML, PHP, and JavaScript, but won't mind learning another language if necessary.
You may be able to use google voice to receive sms messages. You may be able to receive them using pop, imap or xmpp (with varying flexibility on receiving. You would need to have something running on your host provider independent of the web server (or somehow trigger a web page to poll at regular intervals). This would depend on your hosting provider.
Update: I googled for "google voice receive text" and received step by step instructions on how to receive text messages via google voice to email. All you would need to do is connect to gmail (e.g. once per minute) to check if any messages have been received, using imap or pop (you may need to enable imap on gmail too).
Twilio has a cheap, easy-to-use API for SMS messages.
Check it out here.
I have a number of phones on my network and I would like to be able to send a number to one based on extension for it to dial.
I have looked into TAPI and the PHP COM events but I don't understand it all that well and how to apply it to my setup.
Does anyone have any experience with using PHP to send commands to an IP phone on their network?
If these are Cisco IP Phones you can look at using the Ip Phone Services API: http://developer.cisco.com/web/ipps
Look specifically at "Dial" Telephony URI in the Application Development Notes
Each IP phone has a web server on it, you can use standard http(s) posts to send XML commands to the phone. You can completely control the phone in this manner.
You have to understand that client-server communication is a bit unidirectional. From iPhone to server you can easily send messages (and get responses), but to send a message from server to iPhone you have to implement socket connection between them, so the iPhone will always "listen" to what the server is "saying". Also, push notifications are a way to send messages from server to device, but it's not your case, I guess.