创建我自己的推送通知服务,而无需fcm,pusher,

创建我自己的推送通知服务,而无需fcm,pusher,

问题描述:

我想创建一个不基于Google服务或类似服务的通知系统提供程序.实际上,我想获取有关其总体架构以及所需的Android sdk 功能的信息.

I want to create a notification system provider that is not based on Google services or similar. In fact, I want to get information about its overall architecture and needed Android sdk functionality.

对我来说,最奇怪的一点是了解如何向Android设备发送通知.

The most weird point for me is to understand how to send a notification to an Android device.

我的意思是,如何从Internet上数以百万计的其他Android设备中识别安装了我的应用程序的Android设备?

I mean, how can I identify the Android device on which my application is installed from millions and millions of other Android devices on the Internet?

我该如何向他发送信息?我应该为此或类似的东西使用插座吗?

And how do I send information to him? Should I use sockets for this or similar stuff?

简单答案:您不能

在我要更正您的问题之前,pusher和FCM根本不在同一个组中!您可以构建诸如pusher或oneSignal之类的东西,但是不能构建诸如FCM/APNS之类的东西

before everything else i should correct your question, pusher and FCM are not in the same group at all! you can build somthing like pusher or oneSignal or etc but you can not build something like FCM/APNS

您应该了解以下三个简单而重要的句子:

you should understand three simple yet important sentences below:

  1. 当您想将任何东西从 place_1(例如api)拉到 place_2(例如browser_client)时,您通常会拥有一个place_1_resource的标识符(通常是统一的-api的资源定位器)
  2. 当您想将任何内容从 place_1(例如,notification_central_server)推送到 place_2(cellphone_client)时,您最多都有一个place_2_resource的标识符
  3. 您必须了解真正的服务器推送类似服务器推拉技术(如长拉或... )之间的区别,以及您应该知道,此概念的意图是真正的服务器推送,而不是任何带有推送夹克的拉动!
  1. when you want to pull anything from place_1(e.g. api) to place_2(e.g. browser_client) you most have an identifier of the place_1_resource (which commonly is the uniform-resource-locator of api)
  2. when you want to push anything from place_1(e.g. notification_central_server) to place_2(cellphone_client) you most have an identifier of the place_2_resource
  3. you must know the differences between a real server push with server-push-like technologies like long-pulling or ... and you should be aware that what is intended in this concept is a real server push not any kind of pulling with a push jacket!

如果您没有要发送通知的手机的标识符,则服务器不知道该通知的发送位置,因此我们需要一个类似于resource_identifier_like的手机,它实际上是一个 device_token_like ,您只有一种方法可以获取此device_token_like,那就是FCM/APNS

if you don't have any identifier for a cellphone which you want to send it a notification, your server dont know where to send that notification so we need a resource_identifier_like for cellphones which is actually a device_token_like and you have just one approach to get this device_token_like and that is the FCM/APNS

FCM就像是dns服务器,其中包含google支持的每个android设备(几乎每个android设备)的所有标识符,而APNS相同,但适用于苹果设备

FCM is like a dns server containing all identifiers of every android device that google supports (almost every android device) and APNS is just the same but for apple devices

注释1:,即使您的应用程序可以获取其对应的设备device_token_like,如果未在FCM/APNS上注册,也无法将其用于推送通知

note1: even if your app can obtain it's corresponding device device_token_like it can not be used for push notification if its not registered on FCM/APNS

因此,当您获得所需clinet_device的device_token_like标识符时,现在可以使用其他方法将sth发送到该clinet_device.有几种方法,例如SSE,Webpush,HTTP_server_push,Pushlet等.但这些设备的mother_companies不支持这些方法,唯一得到完全支持且标准的方法是与FCM/APNS相同的方法官方网站建议

so when you get that device_token_like identifier of your desired clinet_device now you can use different approaches for sending sth to that clinet_device. there are several approaches like SSE, Webpush, HTTP_server_push, Pushlet and etc but none of these approaches supported by mother_companies of these devices, the only approach that is completely supported and standard is the same approach that FCM/APNS official websites suggests

例如名为 najva 的伊朗公司由于美国的制裁而使用webpush发送通知但是webPush方法在浏览器和android设备上效果很好,但它们甚至没有出现在苹果设备上

for example an iranian Incorporation named najva uses webpush to send notifications because of USA sanctions but webPush method works good on browsers and android devices but they didn't even apear on an apple devices

最后,我应该说,我很欣赏您的好奇心,在开发中减少使用诸如FCM/APNS之类的Benefit_based Inc.所提供的任何东西,但我强烈建议您阅读这些文章和书籍,因为我认为您学得不够:>

finally i should say that i admire your curiosity to less using anything from a benefit_based Inc. like FCM/APNS in your developing but i strongly recommend these articles and books for you cause i think you didn't learn enough:

  1. 推送技术的*
  2. 某人试图做的故事他自己的推送通知服务
  3. 推送技术完整指南-2020版
  4. 具有HTML5 SSE的数据推送应用