【问题标题】:Send push notification with ktor使用 ktor 发送推送通知
【发布时间】:2020-12-31 12:39:46
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: android kotlin push-notification backend ktor


    【解决方案1】:

    使用推送通知,例如:

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

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

    【讨论】:

      猜你喜欢
      • 2015-08-19
      • 1970-01-01
      • 2019-11-07
      • 1970-01-01
      • 2018-02-17
      • 1970-01-01
      • 2016-01-01
      • 2018-02-28
      • 2019-03-18
      相关资源
      最近更新 更多