android - 使用 ktor 发送推送通知
问题描述
我使用 Ktor 框架为 android 应用程序创建了一个后端,我的问题是:
如何将推送通知从服务器发送到手机?我可以为此使用哪些工具?
我想发送通知,每个人都会收到,而刚刚给定的用户也会收到。
我不熟悉 Ktor,但我对这个项目的目标是学习。
解决方案
使用推送通知,如:
import com.pusher.pushnotifications.PushNotifications;
然后在您的应用程序生命周期中的适当时间注册设备令牌,并为您的设备订阅感兴趣的问候:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PushNotifications.start(getApplicationContext(), "YOUR_INSTANCE_ID");
PushNotifications.addDeviceInterest("hello");
}
如果你没有那么多经验也很方便
推荐阅读
- embedded-linux - 我们如何将 THERMAL_DEFAULT_GOV_POWER_ALLOCATOR 设置为 Linux 上的默认热调节器?
- localization - 如何使用本地化文件并覆盖 1 个本地化功能
- ios - 抑制传入的铃声,如 FaceTime 视频
- jquery - 使用jquery过滤没有复选框的数据
- python-3.x - 对象检测 API xml 文件
- reactjs - 如何在 React 类组件中声明和重新分配变量以存储 setTimeout 引用?
- html - 每列带有 flexbox 和边距的结构
- performance - 如果在循环内或只是循环内,哪个更快?
- java - 如何覆盖包含 JSONArray 的 JSONObject 中的值?
- python - 增加 django on dev 支持的请求数量