ios/swift:Quick&肮脏的方式将通知发送到另一个设备?

发布于 2025-01-19 10:07:59 字数 415 浏览 1 评论 0原文

我正在尝试编写一个超级简单的iOS应用程序,仅供个人使用(即它不需要符合任何App Store的内容)。我希望它执行以下操作。假设它安装在我拥有/控制的两台设备上。

在设备 1 上,它有一个按钮,按下该按钮后,会立即在设备 2 上弹出通知。

我可以硬编码特定的 Apple ID、设备 ID 等;如果这仅在两个设备位于同一 LAN/Wifi 上时才有效,那也没关系。我想要的只是让上述内容以尽可能简单的方式工作,并且最好不需要在任何地方的服务器上运行任何内容。

实施起来有多简单?我之前已经建立过一个完整的推送通知系统,但这需要一些服务器端的东西。希望能够在没有任何这些的情况下做到这一点。

====

更新:意识到我在原始帖子中并不清楚我需要在设备 2 上弹出通知,无论应用程序当前是否在该设备上打开/运行。

I'm trying to write a super-simple iOS app, just for personal use (i.e. it doesn't need to conform to any App Store stuff). I want it to do the following. Assume it's installed on two devices, both of which I own/control.

On device 1, it has a button that, when pressed, will immediately cause a notification to pop up on device 2.

I'm fine with hardcoding specific apple IDs, device IDs, whatever; it's also fine if this only works when the two devices are on the same LAN/Wifi. all I want is for the above to work, in the easiest way possible, and preferably without needing anything to run on a server anywhere.

How simply can this be implemented? I've set up a whole push-notification system once before, but that required some server-side stuff. Hoping to be able to do this without any of that.

====

Update: realized I wasn't clear in the original post that I need the notification on Device 2 to pop up whether or not the app is currently open/running on that device.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤凫 2025-01-26 10:07:59

我认为您要搜索的是多台面连接框架。

多人连接框架支持发现
附近设备提供的服务并支持与
通过基于消息的数据,流数据和
资源(例如文件)。在iOS中,该框架使用基础架构
Wi-Fi网络,点对点Wi-Fi和蓝牙个人区域
基础运输的网络。在MacOS和TVO中,它使用
基础架构Wi-Fi,对等wi-Fi和以太网。

来源: https://developer.apple..apple.com/documentation/documentation/multipecerconnectivity 。 /p>

您还可以检查这些教程:

https://www.ralferbert.com/ ios-app-development/multipeer-connectivity/

https://www.hackingwithswift.com/example-code/networking/how-to-to-create-create-a-cereate-a-peer-to-peer-to-peer-to-peer-peer-peer-peer-network-work-network-work-network-使用the-multipeer-connectivity-framework

I think that what you are searching for is multipeer connectivity framework.

The Multipeer Connectivity framework supports the discovery of
services provided by nearby devices and supports communicating with
those services through message-based data, streaming data, and
resources (such as files). In iOS, the framework uses infrastructure
Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area
networks for the underlying transport. In macOS and tvOS, it uses
infrastructure Wi-Fi, peer-to-peer Wi-Fi, and Ethernet.

source: https://developer.apple.com/documentation/multipeerconnectivity.

You can also check those tutorials:

https://www.ralfebert.com/ios-app-development/multipeer-connectivity/

https://www.hackingwithswift.com/example-code/networking/how-to-create-a-peer-to-peer-network-using-the-multipeer-connectivity-framework

初与友歌 2025-01-26 10:07:59

我有类似的要求,似乎需要 APNS(Apple 推送通知服务),因为它是“激活”后台应用程序的唯一方法之一。

那么问题来了,如何让APNS尽可能的无痛呢?似乎结合了 Firebase Cloud Messaging(或 FCM)(用于管理 APNS/发送消息)和 Firebase Functions(帮助管理 FCM 服务器端要求)是一个不错的选择。

I have similar requirements, and it seems like APNS (Apple Push Notification Service) is required for this because it's one of the only ways to 'activate' an application that is in the background.

As a result, then the question is how to make APNS as painless as possible? It seems like combining Firebase Cloud Messaging (or FCM) (to manage APNS / sending messages), and Firebase Functions (to help manage FCM server-side requirements) is one decent option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文