Get JSON data from sniffing Apple push notification - iphone

I have got a wireshark trace of an apple push notification.
But i only have some kind of binary data. Is there a way of retrieving the JSON data with this packet ?

The connection to APNS is encrypted with SSL, so you would need the private key used to establish the connection.

Related

Refreshing firebase when in background

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 a mobile messaging app, should sending a message be triggered from the server or the client?

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)

iPhone Push notificaton

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.

Sending mdm payload

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

Connect to a mobile phone

I know how to make a TCP connection from a phone to a URL (server)
I know how to make an HTTP connection from a phone to a URL (server)
I do not know how to make a connection from a server to a phone
Is there a way to use the phone number of a phone to bridge from voice network to data network of the same provider (VERIZON or AT&T or ROGERS in Canada)?
In essence I wish to find a way to make a "phone call" from a server, over the Internet and over the local data network or WiFi, to a phone, without using any intermediaries
We are willing to pay for this info (optionally)
You can use Push Notification Systems for connecting to the phone. Ideally, you'd want to initiate a pull of data from the device when it receives a push notification from your server. This is because push notifications can handle only small amounts of data.
Another option for you, would be to open a socket on the client device and broadcast this address to your server during startup. Later, your server can directly connect to the listening port on your device, provided the app is still running.
You could send a push message to the phone and let the phone establish the connection.
Just a rough short sketch, maybe this will help you. If I'd had to solve that problem
i would use androids Cloud2Device messaging to tell the phone to connect to a certain
server which you specify in the message from the cloud. Then the phone connects to your command server and you can tell over the connection what the phone should do.
This way you dont have to execute a server on the phone.
Look here
My Ideas
1.Have a look at http://developer.android.com/reference/android/net/sip/package-summary.html
2.Use C2DM(cloud to device message),It will send the message to your app
3.Use XMPP chat client from the server you can send the message to android app after receiving message your app can call(it depends on your logic)
There is no universal one-to-one mapping between cellular phone numbers and IP addresses (e.g. the user could have driven out of cell tower range to a coffee shop with wifi). So this is impossible to do directly.
The services that do seem to do this require a running app on the mobile device to cooperate by periodically connecting to some centralized database using its current IP address, which some server can record in its database for you to do a lookup when want to try to connect to that mobile device. Google "SIP service providers".