ios/swift:Quick&肮脏的方式将通知发送到另一个设备?
我正在尝试编写一个超级简单的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您要搜索的是多台面连接框架。
您还可以检查这些教程:
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.
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
我有类似的要求,似乎需要 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.