iOS API to manage push notifications - ios

This is a long shot, but are there any public (or private) APIs that allow us to read existing push notifications on an iOS device? For example, can an app running in the background poll the system every X seconds to determine if the device has received a push notification from the Stack Exchange app and get its contents?
The thought here is there are some services (such as the Ring Video Doorbell) that do not yet have public REST APIs. But when there is motion detected on the Ring camera, it sends a push notification. Similar to the popular IFTTT service, this app would poll for that notification on the device and then do something based on criteria set by the user.
I imagine there has to at least be a private API since Apple shows the device's recent notifications in the Notification Center.

Even if it was possible to use an unsupported API that violated app security, the contents of the push notification are encrypted and you may not be able to read the contents.
However, Apple's Developer site has information on relaying and interacting with other app's push notifications over bluetooth for a bluetooth ANCS.
"The purpose of the Apple Notification Center Service (ANCS) is to
give Bluetooth accessories (that connect to iOS devices through a
Bluetooth low-energy link) a simple and convenient way to access many
kinds of notifications that are generated on iOS devices."
https://developer.apple.com/library/content/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html#//apple_ref/doc/uid/TP40013460-CH2-SW1
This may not be applicable to you, but it is Apple's approved method for interacting with, and relaying push notifications from other apps to bluetooth devices.

No, that's not possible. It seems that it will be a privacy issue if other apps will read other apps push notifications content.

Apple would never give such API private/Public, this will violate apps security.You can only read your apps push notifications.
if you use private API , there is good chance that your app will be rejected when you submit to app store.
some possible solutions to your app.
1) Figure out is there any way your app gets that push notification.
2) Or you have to use Inter-App Communication.

I interpret this question to be asking specifically in the lens of a IFTTT device that could already read/write data to a "standard" IFTTT app, and you're wondering how that's done. To me, that's the question, and not asking about a hacky private API push notification system.
With that in mind, the solution is generally referred to as HomeKit from what I know. It's one of Apple's "Kits", with general docs found here
What I think you're looking to do is more along the lines of database observation, where you're maybe looking to build some aggregator app of this data set stored on the device (which Apple has a standard method of asking users for permissions, and is fully allowed on the system just like Camera/Health/Photo permissions, etc).
Observing HomeKit database changes is found at a developer doc linked from the first, but found here
I haven't used this before myself, but from the docs, I can see there are methods for observation using regular old iOS KVO:
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(updateHomes:) name:#"UpdateHomesNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(updatePrimaryHome:) name:#"UpdatePrimaryHomeNotification" object:nil];
There's a lot more info there, and I'm sure StackOverflow itself (and old WWDC videos of course) have lots of info on HomeKit.
I hope this was the intended interpretation the question-asker meant.
Similarly, though, each of the supported channels for events (HealthKit, MapKit, etc) can send you "push notification" type updates about what your user is doing with built-in APIs.
If you're attempting to simply read from other application's push payloads, then the other answers are correct and that is not possible on a pure privacy basis that Apple sandboxes your application: Apple Sandbox Docs Link

Related

Wake up the Voip app from background , when a call received in standard iphone application

What my requirement is "I need to wake up my application from the background when a call comes in my iPhone".Is Any way to do so? Shall we get a unique number for the each user in
You'll need to use PushKit notifications and CallKit that can start the app even when the app is killed.
The CallKit is not really absolutely necessary, since it "just" allows you to provide standard calling interface. But it is a very nice feature to have - user is used to standard iOS interface for answering/declining calls, so I would definitely recommend to go with CallKit, instead of just standard notifications.
You can take a look at this tutorial, or just google together the PushKit, CallKit and Voip to get other relevant tutorials.
VoIP Push notifications is your solution.
I don't like the "link" answers myself, but here is how to do it:
Voice Over IP (VoIP) Best Practices (Apple documentation)
Roughly saying, VoIP pushes allow you to wake up your application and your code will be executed.
You may also be interested in CallKit, if you're working on soft-phone application.

PushKit: Can we use push kit(VoiP Push) in Chat Application without using VoiP

I want to sync my local DB with server when Push notification came, but I am not able to do it with Silent Notification because application:didReceiveRemoteNotification:fetchCompletionHandler not called when app killed by user. So, I did not know how to do it, then I read about push kit but don't know is it possible to use push kit without VoiP feature. Please tell me is it possible or not??
If not, suggest me any other idea , how will I run background task when app killed by user??
In my experience as well as others on SO - you get rejected for trying to leverage VOIP as a workaround. See below for actual response from apple dealing with a similar attempt.
2.16: Multitasking apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc.
2.16 We found that your app uses a background mode but does not include functionality that requires that mode to run persistently. This behavior is not in compliance with the App Store Review Guidelines.
We noticed your app declares support for VoIP in the UIBackgroundModes key in your Info.plist but does not provide any Voice over IP services.
We recognize that VoIP can provide "keep alive" functionality that many app features would like to use. However, using VoIP in this manner is not the intended purpose of VoIP, which, as indicated in the iOS Application Programming Guide, is that: "A Voice over Internet Protocol (VoIP) application allows the user to make phone calls using an Internet connection instead of the device's cellular service."
Seems that the only way to restart the app when it was killed by user is to use PushKit.
It is possible to use PK framework in your app without Voip functionality, but I can't guarantee you, that your app will not be banned while posting to AppStore.

iOS: use VOiP notification instead of "normal" notif

We just add VOiP capability to our app (messaging app), now we will use VOiP (PushKit Framework).
Can anyone tell me if we can use only that notifications (VOIP notifications)? Meaning even for text message for example (not for a call)? I talk about Apple Appstore Guides, they can reject the app or block the notifications if they found that we use that notification to notify the user about other things then a VOIP call?
The answer is yes, i used the VOiP notification for a no-voip notifications (like a text message) and Apple accept the app (and i can can confirm, after some tests, that whatsapp use the same thing as my app).
You need to implement VOIP functionality in order to not to be rejected. I've tried to use it for messages between users and it was not approved. So if you really don't have VOIP functionality, modify your server to your needs.
I have also implemented VOIP push notification in our app. But app is rejected by app store by saying
"We continue to find that your app declares support for VoIP in the UIBackgroundModes key in your Info.plist, but it does not include any Voice over IP services.
Please revise your app to either add VoIP features or remove the "voip" setting from the UIBackgroundModes key.
We recognize that VoIP can provide "keep alive" functionality that is useful for many app features. However, using VoIP in this manner is not the intended purpose of VoIP.".

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 :)

ios alternative to push notification by using iCloud like "find my iPhone"

I have been looking at the "find my iPhone" app and it seems like it is using iCloud and no push notification to receive a alertView about a notification. By having some mechanism in the background running and alerting the user once it receives a notification.
What I am wondering is that is this app a special exception Apple made for this app, and all other apps have to do push notification? Or can I make an app that runs in the background just like the "find my iPhone" app and communicate via iCloud.
Thank you in advance.
Apple uses iCloud for Find My iPhone, yes, but I believe their reason for this is tying it to your iCloud account so that if your phone is stolen, you can log in your account at icloud.com to attempt to track it. The Find My iPhone app itself works by pinging the GPS location, saving that location, and syncing it with iCloud. For general developer use however, there's no direct API for communicating via iCloud, nor is it likely there will be. iCloud's main purpose is synchronization and backup, and since Apple already has the Push Notification service in place it wouldn't make sense at this point to put that in iCloud. What functionality are you wanting that Apple's Push doesn't allow?
When your app is in the foreground you have the capability of receiving data from an external source a number of different ways. However when your app is terminated either by the user or the system memory watchdog, Push Notifications are the only real route. So at this stage, integrating the APNS is your best solution. There's a few great services that make APNS integration relatively painless, such as Urban Airship.

Resources