iOS send request directly to APNS without server - ios

On Android, to send a notification all you need to know is GCM id of a device you want to notify. Assuming my user knows the id of another user, he sends a message directly to GCM server, what decreases the load on my server. I don't have experience building iOS apps, so I want to know if the same approach is possible for iOS devices. If my user knows id of another apple device, can he send a request directly to APNS?

Sending a push is just a matter of posting data to apple servers.
You can do it from your server or the device. It's up to you.

Try NWPusher. It contains an iOS demo application that shows how to send push notifications from iOS to iOS.

Related

Send push Notification to Multiple Apps

I wanted to know if it is possible to send a Push to App A and App B at the same time, and if the user has both apps installed, only one will be shown.
Edit:
I was trying to prevent duplicate Notifications to be shown if the user has both Apps installed. But it seems this is not possible to do on the App side. We will have to come up with something server side to prevent duplicate messages to be sent.
Each app has its own deviceToken on that device. To send pushes to both apps you would need to send the push to both device tokens. The device will display both notifications.

Sending Apple Push Notification directly from device to device

As far as I can read, it is technically possible to initiate an Apple Push Notification from an iOS App instead of via a server/service.
It would require the push notification certificate to be bundled with the app, and device tokens for the receiving devices must be exchanged.
Offhand this seems like a usable solution for some notification scenarios, but are there other limitations? Would such a setup not be accepted in an App submitted to the app store? Would exchanging device tokens pose some sort of risk? It would save the cost of a notification service and it would distribute the processing to the clients instead of the server.
What am I missing?
try NWPusher...
this is a third party but sends notification from ios to

iOS - Push Notification from iOS App to APNs without a server or third party

I'm looking for a way to send the payload for remote notification to the APNs from an iOS App. i'm pretty sure there's a way, but i'm not very good when it comes to communicating with a server and Json.
i've looked into NWPusher, swift Pusher and others. i couldn't find a clear instructions.
any help would be appropriate.
thanks
You need to store all token in a database then get all token in your app to send the notifications.
Is not possible to simply get all token of all devices using your app. Tokens must be store somewhere.
No you cannot do it. Push Notification is not meant be sent from your app.

How do iOS Push Notifications work?

How do iOS "push" notifications get delivered to a particular device without that device needing to poll a server?
For example, let's say I have received a new message on Facebook. Facebook notifies Apple that my device should receive a notification as such. But how does Apple know which device/IP to push the message to?
Each device can be updated with data using their own unique device tokens. This picture explains everything . .
It was too much for me to put in a comment so.
From the documentation.
Apple Push Notification service (APNs) propagates push notifications to devices having applications registered to receive those notifications. Each device establishes an accredited and encrypted IP connection with the service and receives notifications over this persistent connection. Providers connect with APNs through a persistent and secure channel while monitoring incoming data intended for their client applications. When new data for an application arrives, the provider prepares and sends a notification through the channel to APNs, which pushes the notification to the target device..
I suggest reading the documentation for more information and how to use and configure. It's all there.
Push Notifications
I created an infographic to explain the workflow of push notifications. Hope this is helpful.
Device does not keep polling the server for the push notifications.
To keep it simple, consider an iPhone is connected to internet. On connecting to internet iPhone establishes connection to Apple Push Notifications server this connection is open connection which means data can be thrown to iPhone from server the moment data arrives to server.
Apple does not use HTTP protocol for Push notifications but if you understand HTTP Protocol its almost a similar methodology.
http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push
There is a really nice exaplanation of push notifications in this article.
In iOS, apps can’t do a lot in the background. Apps are only allowed to do limited set of activities so battery life is conserved.
But what if something interesting happens and you wish to let the user know about this, even if they’re not currently using your app?

How should I send push notifications only to active devices?

I have an iOS app with a Rails backend (and frontend). I am using Parse for push notifications.
I am trying to figure out the best way to only send push notifications that will be received; that is, I want to avoid sending them to:
Users who only use the web app and don't have the iOS app
Users who had the iOS app but then uninstalled it
The way that the Parse Push API works is that I can broadcast a notification on a certain channel, and any device that is listening to that channel will receive the notifications. Therefore, I am planning to make separate channels for each user.
Obviously, I am going to need to store some sort of information on the server side about who is running the iOS app. I'm curious as to whether anyone out there has experience solving a problem like this and can offer any wisdom. Thanks!
Parse already stores information about who is running iOS and Android apps. Check out the Data Browser, there is an Installation table with a deviceType field.
Have the iOS app register a unique (per-user) channel. If you're only sending push notifications on user channels, it will only be sent to users who have installed the iOS app.
There's not much you can do for users who had the iOS app but uninstalled it. Apple doesn't provide a way for applications to run any code before being uninstalled, so you can't unregister the device with Parse. I'm not sure if Parse does this, but Urban Airship polls the APNS servers and removes devices that have had the app uninstalled after a certain amount of days.

Resources