Is it possible send push notification without server side?
For example my device cominicates with apns directly without server?
While technically it is possible, it isn't something you would want to do.
You would have to embed your certificate inside your app. This would be a BadThing. Anyone who wanted to could then extract your certificate and start sending push notifications pretending to be you.
The apns is only there to push notifications out to the devices. It isn't a two-way communication thing other than the devices register with it. Once they have registered, the apns sends messages when you request them.
If you don't want to write your own server, there are others available that are already written like the excellent (I don't work for them - just a happy user) Urban Airship.
Related
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/
In apps like Snapchat, Line, Kik, Groupme, etc., users have their contact list from which they can send messages to multiple people.
I'm building a messaging app that has similar features and at first was going to just add a server and let the server store device tokens and send notifications from the server. (By the way I am using Urban Airship to send push notifications.) So the way I had imagined was like this:
User A writes "Hi there" to User B
"Hi there" gets posted to my server where it gets stored in DB for later retrieval
After 2 is successful, the server posts "Hi there" to Urban Airship server (Server has the contact list which has all the device id info)
Then I realized how this could be done client side as well, that is, if it's ok to store device tokens of a user's contacts on their apps. So this is how it would work:
User A writes "Hi there" to User B
"Hi there" gets posted to my server where it will be stored in DB for later retrieval
After 2 is successful, the client (iPhone) posts "Hi there" directly to Urban Airship server (The app stores all of the user's contacts' device ids in core data)
I'm a newbie at push notification so don't even know if it's safe/ok to store device tokens on the client side, but I feel like it would be much more efficient in terms of server load (my server) since all the push notifications requests are sent from the client. Any suggestions on what the best practice is? Thank you
Actually this sounds like a very bad idea.
1. When a user joins the network you need to publish the token to all users connected to it.
if you have great amount of new users, its not so smart.
2. A simple sniffer (Network sniffer \ openSSH sniffer) can detect users tokens.
Security wise, it's not a good idea.
3. Also, it's overloading the user's device.
Rule of thumb, all overhead should be handled by the server.
Consider this:
-User A send "Hi there" to user B
User A sends the msg to the server
Server saves the msg + sends "OK" to user A
User A receives the "OK" and now sends the msg again, now to user B
User B gets the msg and sends to user A "OK".
How will you know the msg got to user B? will he send an "OK" to the server as well?
To make things short,
Go with the first method, the second one is very not recommended..
Good luck :-)
If you are using Apple Push Notifications service, you should definitely send the notifications from the server to the devices, and not directly from device A to device B. Apart from the reasons mentioned in the other answer, there is the issue of maintaining a connection with the APNS servers.
If each device can send its messages directly to APNS, each device would have to maintain its own TLS connection to APNS servers. And since devices often connect and disconnect from the internet, that connection would close and reopen frequently. Multiply that by the number of devices on which your app is installed, and you will have a large number of short lived connections to APNS. That would probably get your certificate revoked.
Keep your connections with APNs open across multiple notifications; don’t repeatedly open and close connections. APNs treats rapid connection and disconnection as a denial-of-service attack. You should leave a connection open unless you know it will be idle for an extended period of time—for example, if you only send notifications to your users once a day it is ok to use a new connection each day.
(Source)
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
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..