首页 > 解决方案 > 使用 ktor 发送推送通知

问题描述

我使用 Ktor 框架为 android 应用程序创建了一个后端,我的问题是:

如何将推送通知从服务器发送到手机?我可以为此使用哪些工具?

我想发送通知,每个人都会收到,而刚刚给定的用户也会收到。

我不熟悉 Ktor,但我对这个项目的目标是学习。

标签: androidkotlinpush-notificationbackendktor

解决方案


使用推送通知,如:

 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");
}

如果你没有那么多经验也很方便


推荐阅读