Push notification (urban airship) questions - ios

I want to use "push notification" in my apps, In general, I have a basic knowledge about push notification and I want to use urbanairship service for message broadcasting.
Also, my apps have not centralized web service, handle device's tokens, therefore, I have no solution to keep tracks of device tokens. ( uninstalled apps etc. )
After analyzing urbanairship api, I noticed that urbanairship do that for me, but I'm not sure 100%, so am I understand correctly?
Also, I think that registration of device token into urbanairship servers made by urlrequest like:
Convert device token to hex formatted string.
Creating urlrequest like: https://go.urbanairship.com/api/device_tokens...
Then we call NSUrlConnection.
Or urbanairship has built-in solution for it too and I missed it.
Thank you.

Related

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.

APN push notifications for chat

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

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.

Use of silent APNS push notifications to send token without user notification?

I've checked through other questions and responses here at StackOverflow but couldn't see something exactly like this; I would like to be able to push a token via APNS. The purpose of this is to verify that a subsequent user request to a restful web service comes from an iPhone device and not from a non-iPhone source (it's trivial to change HTTP headers to fake looking like an iPhone request).
Couple of questions:
Is it permissible under Apple Guidelines to insist that push notifications be enabled ?
Is it possible to send a SILENT push notification carrying some small text payload?
Does anyone know if this would pass Apple's scrutiny or run afoul of their guidelines
Many thanks.
You cannot force user to accept push. A user always has option to refuse.
Yes you can send a notification with no sound / text, and add metadata.
Yes, sending a token seems an acceptable use for Apple.
However, I do not personally think this use case does cleverly fit the push use case at all. You will have to many edge case to make it reliable enough (delivery delay and non garantee of delivery, etc)
It is easier to have other mechanisms in place (like secret + signature in the URL by the app).
I see that folks are still looking at this question. FYI, for enterprise dev which is the area I mostly work in, you simply register the iOS app as a VOIP app and it will accept silent notifications without a need for the user to approve.

Resources