用于管理推送通知的iOS API

时间:2021-11-16 01:37:40

This is a long shot, but are there any public (or private) API's that allow us to read existing push notifications on an iOS device? For example, can an app running in the background pole the system every X seconds to determine if the device has received a push notification from the Stack Exchange app and get it's contents?

这是一个很长的镜头,但有没有任何公共(或私人)API允许我们在iOS设备上阅读现有的推送通知?例如,在后台运行的应用程序是否可以每隔X秒对系统进行一次极限操作,以确定设备是否已从Stack Exchange应用程序收到推送通知并获取其内容?

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 pole for that notification on the device and then do something based on criteria set by the user.

这里的想法是有一些服务(例如Ring Video Doorbell)还没有公共REST API。但是当在环形摄像机上检测到运动时,它会发送推送通知。与流行的IFTTT服务类似,此应用程序会在设备上触发该通知,然后根据用户设置的标准执行某些操作。

I imagine there has to at least be a private API since Apple shows the device's recent notifications in the Notification Center.

我想至少必须有一个私有API,因为Apple会在通知中心显示设备最近的通知。

4 个解决方案

#1


10  

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.

即使可以使用违反应用安全性的不受支持的API,推送通知的内容也会被加密,您可能无法读取内容。

However, Apple's Developer site has information on relaying and interacting with other app's push notifications over bluetooth for a bluetooth ANCS.

但是,Apple的开发者网站提供了有关蓝牙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."

“Apple通知中心服务(ANCS)的目的是提供蓝牙配件(通过蓝牙低能耗链接连接到iOS设备),这是一种访问iOS设备上生成的各种通知的简单方便的方法。”

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.

这可能不适用于您,但它是Apple批准的方法,用于与其他应用程序与蓝牙设备进行交互,并将推送通知转发给蓝牙设备。

#2


9  

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

不,那是不可能的。如果其他应用会读取其他应用推送通知内容,这似乎是一个隐私问题。

#3


4  

Apple would never give such API private/Public, this will violate apps security.You can only read your apps push notifications.

Apple永远不会将此类API私有/公开,这将违反应用程序安全性。您只能阅读应用程序推送通知。

if you use private API , there is good chance that your app will be rejected when you submit to app store.

如果您使用私有API,那么当您提交到应用商店时,您的应用很可能会被拒绝。

some possible solutions to your app.

一些可能的应用程序解决方案。

1) Figure out is there any way your app gets that push notification.

1)弄清楚你的应用程序是否有任何方式获得推送通知。

2) Or you have to use Inter-App Communication.

2)或者您必须使用应用程序间通信。

#4


1  

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.

我将此问题解释为在IFTTT设备的镜头中专门询问,该设备已经可以读取/写入“标准”IFTTT应用程序的数据,并且您想知道它是如何完成的。对我来说,这是一个问题,而不是询问一个hacky私有API推送通知系统。

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

考虑到这一点,解决方案通常被称为HomeKit。它是Apple的“Kits”之一,这里有一般文档

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

我认为你想要做的更多的是数据库观察,你可能正在寻找构建存储在设备上的这个数据集的聚合器应用程序(Apple有一个要求用户获得权限的标准方法,并且完全允许在系统上,就像相机/健康/照片权限等)。

Observing HomeKit database changes is found at a developer doc linked from the first, but found here

观察HomeKit数据库更改是在第一个链接的开发人员文档中找到的,但在此处找到

I haven't used this before myself, but from the docs, I can see there are methods for observation using regular old iOS KVO:

我之前没有使用过这个,但是从文档中我可以看到有使用常规旧iOS KVO进行观察的方法:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateHomes:) name:@"UpdateHomesNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePrimaryHome:) name:@"UpdatePrimaryHomeNotification" object:nil];

[[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 * 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.

那里有更多的信息,我相信*本身(当然还有旧的WWDC视频)在HomeKit上有很多信息。我希望这是问题者的意思。同样,每个受支持的事件通道(HealthKit,MapKit等)都可以向您发送有关用户使用内置API执行操作的“推送通知”类型更新。

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

如果您尝试简单地从其他应用程序的推送有效负载中读取数据,则其他答案是正确的,并且这在Apple隐藏您的应用程序的纯隐私基础上是不可能的:Apple Sandbox Docs Link

#1


10  

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.

即使可以使用违反应用安全性的不受支持的API,推送通知的内容也会被加密,您可能无法读取内容。

However, Apple's Developer site has information on relaying and interacting with other app's push notifications over bluetooth for a bluetooth ANCS.

但是,Apple的开发者网站提供了有关蓝牙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."

“Apple通知中心服务(ANCS)的目的是提供蓝牙配件(通过蓝牙低能耗链接连接到iOS设备),这是一种访问iOS设备上生成的各种通知的简单方便的方法。”

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.

这可能不适用于您,但它是Apple批准的方法,用于与其他应用程序与蓝牙设备进行交互,并将推送通知转发给蓝牙设备。

#2


9  

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

不,那是不可能的。如果其他应用会读取其他应用推送通知内容,这似乎是一个隐私问题。

#3


4  

Apple would never give such API private/Public, this will violate apps security.You can only read your apps push notifications.

Apple永远不会将此类API私有/公开,这将违反应用程序安全性。您只能阅读应用程序推送通知。

if you use private API , there is good chance that your app will be rejected when you submit to app store.

如果您使用私有API,那么当您提交到应用商店时,您的应用很可能会被拒绝。

some possible solutions to your app.

一些可能的应用程序解决方案。

1) Figure out is there any way your app gets that push notification.

1)弄清楚你的应用程序是否有任何方式获得推送通知。

2) Or you have to use Inter-App Communication.

2)或者您必须使用应用程序间通信。

#4


1  

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.

我将此问题解释为在IFTTT设备的镜头中专门询问,该设备已经可以读取/写入“标准”IFTTT应用程序的数据,并且您想知道它是如何完成的。对我来说,这是一个问题,而不是询问一个hacky私有API推送通知系统。

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

考虑到这一点,解决方案通常被称为HomeKit。它是Apple的“Kits”之一,这里有一般文档

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

我认为你想要做的更多的是数据库观察,你可能正在寻找构建存储在设备上的这个数据集的聚合器应用程序(Apple有一个要求用户获得权限的标准方法,并且完全允许在系统上,就像相机/健康/照片权限等)。

Observing HomeKit database changes is found at a developer doc linked from the first, but found here

观察HomeKit数据库更改是在第一个链接的开发人员文档中找到的,但在此处找到

I haven't used this before myself, but from the docs, I can see there are methods for observation using regular old iOS KVO:

我之前没有使用过这个,但是从文档中我可以看到有使用常规旧iOS KVO进行观察的方法:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateHomes:) name:@"UpdateHomesNotification" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePrimaryHome:) name:@"UpdatePrimaryHomeNotification" object:nil];

[[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 * 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.

那里有更多的信息,我相信*本身(当然还有旧的WWDC视频)在HomeKit上有很多信息。我希望这是问题者的意思。同样,每个受支持的事件通道(HealthKit,MapKit等)都可以向您发送有关用户使用内置API执行操作的“推送通知”类型更新。

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

如果您尝试简单地从其他应用程序的推送有效负载中读取数据,则其他答案是正确的,并且这在Apple隐藏您的应用程序的纯隐私基础上是不可能的:Apple Sandbox Docs Link