APN push notifications for chat - ios

I'm trying to add notifications to a private chat app that uses Firebase, unfortunately Firebase has an APN service but it must be configured and needs also a server app to manage it. I'd like to have the user notified when someone is texting him while the app is in the background. The problem is that APN (Apple Push Notifications) requires a server with a certificate and that is ok with me, but I'm looking for a way to send push notifications from an iOS device to another device, I mean device-to-device push notifications and the server has just to relay the messages as they are. In my case the APN server should only relay the messages that it receives from a source device to the destination device. I couldn't find a way to obtain that without writing sever code. I want to use pre-built existing services. Has anybody any idea on how to send push notifications from one device to another without configuring and writing server apps? I tried a workaround using the background fetch iOS feature, but the system si randomly giving my app execution time... and that means that my app could wait hours before being started by the system... so that is not a viable solution. Please help

Ok, probably what I found out could be helpful for others. Actually
what I'm looking for can be directly integrated in the app. You need a library like NWPusher (free on GitHub) which can be imported, and with just a few lines of code and the APN device token you get from the system, it is possibile to implement APN notifications... easily, but most importantly... for free.
UPDATE
Check also APNS framework on GitHub. It's written in Swift 3.0 and it supports the latest features.

You are essentially looking for a messaging / chat API to handle device-to-device communication. You might want to try Pusher or PubNub

Related

Send push notifications to Apple devices without connecting to APNS

I know this question can sound a bit strange, but I want to ask this anyway (feel free to downvote): is it possible to send push notifications to an iOS device without connecting to an Apple server? My idea is to send a push from my private server, not Apple's. Is this possible?
Info from developer.apple.com
Remote notifications—also known as push notifications—arrive from
outside a device or a Mac. They originate on a remote server—the app’s
provider—and are pushed to apps on devices (via the Apple Push
Notification service) when there are messages to see or data to
download.
There is no way to do it without using Apple Push Notification System (apns).
Well, the general answer would be - no.
It is not possible due to Apple's restrictions.
There may be different providers to an APN, but as the documentation suggests, there has to be a direct connection to an APN.
For more informations, please check out Apple's Documentation on Apple Push Notification Service.
However, I found this post where a user suggests using a service called Urban Airship - I have not tried this myself, so I don't know if and how it would work, but you may check it out :)

Is it possible to send push notification from one iOS app to another iOS app?

I am not very familiar with push notifications. But is it possible to send push notification from one app to another? I know you need a server to send notifications but is it possible implement that in an app.
Short answer: No, pushes are sent from a server to a server.
Long answer: Of course, it's not common practice, but lots of fun.
To send out a push notification to an Apple device, you will need to connect with the APNS server and then send your notification in data format. Although this is usually done from a server, it can just as well be done from an iPhone or iPad.
If you want to get going yourself, I recommend reading all the documentation Apple provides on this topic (start here). Everything you need to know is in there, but you will need to pay attention to the details in order to get this to work.
An easier way to get going is by using NWPusher. This is an iOS framework that provides all the tools you need to push from iOS to iOS. It even includes an iOS demo app that does this:
NWPusher - Push from iOS
Just a small warning: In order to push from iOS, you will need to include the push certificate and private key in the app bundle. This is not a secure place to keep such a private key and you definitely don't want your app's push certificate to leak.
Enjoy!

iOS Sending a Push Notification From an iOS App, APNS

Is there anything preventing SENDING a push notification FROM an iOS application? There are reasons for my madness. If so, are there any good examples out there? I have code that should be working and if there is no blocking reason, I will post the code.
I tried on Verizon and AT&T. Would want it over a carrier for now.
Please do not comment on why, etc.
[addition]
This would not be for a public app, testing internal only.
I don't see any reason what this wouldn't work. You'll have to include the push certificate with your application, and your users will have to download a new version of your app every time the certificate expires (which means once a year). You'll also need to send to each device all the device tokens of devices it should send notifications to.
The sending code should be the same as it would be in a server that sends push notifications, but you would have to implement it in objective C.
All in all it doesn't seem like a good idea, since you'll need a server anyway (for each device to get the device tokens of other devices), so it makes more sense that the server will do the sending.
Actually yes - there are a few things that prevent you from sending push notification from iOS.
Even if you manage to install (use in your app) certificates needed to properly connect to Apple's APNS server their policy is to start blocking clients that create many short connections.
So for public app you would need to use a "normal" way of setting up your PHP server that manages communication with APNS. Otherwise many public IP's (devices) using your credentials would lead to blocking your app APNS certificate.
If this would be just for private use then there is no reason not to give it a try.

Is there a workaround for APNS Feedback?

The iOS app i developed uses APNS. Locally i could simulate the whole process from saving device tokens, sending push notifications to deleting device tokens with help from APNS feedback successfully. Also in production it worked for a short time.
Now my webhoster closed port 2196. Port 2195 is available, so sending notifications is still possible. I do not want my ios app to get on the blacklist, so is there any other way to register whether a user has deleted my app on their device? Or will i have to look around for another webhoster, who has both ports open? Any suggestions?
You'll have to look for another host or look into 3rd party solutions that have a Feedback API. I know Urban Airship had one (haven't used it in a while) and may be giving access to it freely.

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