I am currently making an app where users can send messages to their counselors at camp, without releasing their phone numbers. If the user sends a message, how can I check on the counselors app if they received a message, and if so, display a push notification, even if the app is in the background.
You will need to use Apple Push Notification Service (APNS).
To do this you will need a BaaS server with some PHP code and certificates to access Apple's servers. Each device authenticates to the APNS server when the app is loaded and provided a key. Then the device sending a message will send a request to your server and the server will process the data through Apple to whichever remote tokens you have specified in the payload.
Great write up here... https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/
Related
I am developing a chat app using ejabberd server for both IOS and Android. I also wrote a module for ejabberd to get the offline messages sent to my own server api .
my own server api will send notifications to the IOS/Android platforms using FCM.
On the client side , if the application is in the foreground or the background , it will stay connected to ejabberd and if the client receives the message then ejabberd will send the message delivery status.
I am facing an issue while the app is terminated ( service is not running ) which means it is not connected to ejabberd (offline) . if i send a message to this app while it is not terminated , it will receive a notification but the message still undelivered . how can mark the messages as delivered when receiving the notification while the app is terminated.
to explain it more , the same functionality is working fine with whatsapp :
device A has whatsapp installed and whatsapp was turned off (terminated)
Device B has whatsapp running
Device B sends a message to device A
Device A receives a whatsapp notification
Without doing anything on Device A , the message status on Device B is marked as delivered .
How can I implement this scenario with ejabberd ?
In case someone went into this issue , here is the solution that I implemented with help of #Mickaël Rémond from his answer.
I configured ejabberd to send the offline messages to an http service ( your own server) please refer to this link for further on how to do it
your server should catch the above call and generate a notification message (FCM ) in my case and send it to recipient device
recipient device will catch the notification which includes the message
recipient device will call http service (your own server backend)that responsible for sending the deliver ack to the original sender . you need to pass from, to , stanzaId , vhost with this call
backend server will use ejabberd-api (set of exposed apis to manage ejabberd through rest apis calls) to send delivery message using this api
please note the following notes also :
sending the delivery message from your own server to ejabberd will not delete them from ejabberd database
if the user re-connected to the ejabberd server then the recipient will receive the message again from ejabberd .
It is probably too complex for a simple Stack Overflow question, as you need to integrate several moving part on client and server:
You need to execute code in background when receiving push notifications on iOS (you need that property set on your app in your app provisioning profile and have code to handle that). The client will initiate an HTTPS query to let the server know that the message was delivered.
You need to have an endpoint that will get the delivered HTTPS calls and generate either a message ack or a chat marker on behalf of the user and route it in ejabberd.
In real world, this is not enough if you want to take into account the fact that you can only have 1 push in the queue on APNS. If you have several messages sent while the device is not on the network, you will need to have the device check all received messages while offline on the server, otherwise you will lose messaging.
You need to rely on XMPP Message Archive Management (MAM) to handle that history.
As you see, this is not a simple few tens of line of codes but need real design and involved work.
I'm kind of starting programmer and on Objective-C. So I want to make an app for iOS that receives messages from a server. These messages are inputed manually, and send to all iOS connected to the server. People connected will receive a Push Notification, if they aren't connected to internet they will receive when they do and run the app.
So my question is: do I need to use a server to do this (sending messages for multiple iPhones)? In case of yes, with is the best server? TCP/socket?
If your only purpose behind using is to send push notifictaion message, then you dont need to spend on that. There are some service providers available which allow you to send notification from there website. for ex: you can use urbanairship. You need to register device token from your Xcode project using their SDK, and then you can send notification from their website.
Thanks!
I am developing an MDM solution.
I have installed a configuration profile on device.
So I have all the required things like
Device Token, Push Magic String, UDID of device, etc.
Now I want to send a mdm payload to the device using APNS.
I am able to send a simple alert message to the device, but I need to send a mdm payload.
I am not sure how to send a plist(XML) to the device using APNS.
I am using php to send Push notifications.
Please if someone could help me how to send a mdm payload to the device.
Thanks,
Manmay
The MDM payloads are not public available. To use mdm you must register at apple (ios-mdm#apple.com).
install iphone config utility ..
create a new Configuration profile...
while creating go to mobile device management tab..
we can find server url and check in url...
we need not know that mdm payload cannot be send through apple push notification service..
only we can send {mdm:"push magic token"}..
first try to install mdm payload manually..
after installation the device with payload will Initially (first time) will respond to check in url sending push magic token.. device token.. and udid..
then using push magic token we can send the push notification.
then the device will poll commands through server url..
we can send commands like examples lock .. unlock.. in response (mime type : plist)and we can terminate connection by sending 200
Actually you can't send the payload directly to the device. Here's how the delivery work :
MDM Server triggered APNS
Device receive the APNS and send idle response
MDM Server response the device query with Payload
Device send ACK to server
So the APNS work just for triggering the device to connect to server and then query what command available for that device.
prepare xml in a txt file and response it as a flow, it's ok
How the server know whether the push notification received by iPhone(and also the action that user performed (tapping "Cancel" or "View")). Do i need to send separate message from client to server that "Notification received" or Is There any mechanism to get status from APNS by server so that I can avoid sending a message from client side.
I have checked enter and Push notification guide, but I didn't find any information.
As per the documents there is no guarantee for a notification to be received successfully. Also APNS won't inform the server about a successful delivery of push notification. So better
on the method
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
//you can send a message to the server so that server can make sure that notification is delivered successfully.
}
FYI : If notifications to a particular device token is getting failed continously the APNS will inform about that.
From apple docs
"Apple Push Notification Service includes a feedback service that APNs continually updates with a per-application list of devices for which there were failed-delivery attempts. The devices are identified by device tokens encoded in binary format. Providers should periodically query the feedback service to get the list of device tokens for their applications, each of which is identified by its topic. Then, after verifying that the application hasn’t recently been re-registered on the identified devices, a provider should stop sending notifications to these devices. "
I create application and i want to use push notification in it. But application use outside servers (i nave not access to config this servers), e.g. XMPP server(xmpp.org, jabber.org etc.).
As i understand from apple documentation, for get notification, i must send notification with token to APNS from server (my server). Isn't it? How i can send notification from outside server?
I know it is possible, for example IM+.
its not possible to create it without sending notifications to apple server... but if you think out of the box you can create a layer with your own server which will act like a mediator between your app and your outside server. now you have control over this mediator server here you can send message to apple server to send push notifications to server..