如何从离子移动应用程序发送/接收推送通知?

问题描述:

我有一个使用Ionic框架构建的消息传递应用程序(在cordova上)。我打算为Android构建这个,我想要一种使用javascript / ionic从应用程序发送和接收推送通知的方法。

I have a messaging app built using the Ionic framework (on cordova). I plan on building this for android, and I'd like a way to send and recieve push notifications from the app using javascript/ionic.

是否有任何好的教程关于如何设置这样的东西?

Are there any good tutorials out there on how to go about setting something like this up?

示例应用程序由Holly Schinsky提供。它的核心是使用 PushPlugin ,这是处理Cordova上的推送通知的标准方法。关于该主题的GitHub存储库文档提供了相当广泛的教程。主要方法是 pushNotification.register ,它注册设备以监听推送通知。

There is example application made available by Holly Schinsky. The core of it is the usage of PushPlugin which is the standard method to handle push notifications on Cordova. There is quite extensive tutorial provided for this subject on their documentation on that GitHub repository. The main method is pushNotification.register which registers the device to listen for push notifications.

如果您需要在本地触发通知,您可能需要查看本地通知插件。有了它,您可以添加要在设备上显示的通知,而无需外部服务来发送推送通知。

If you instead need to trigger notification locally, you might want to take a look at Local notification plugin instead. With it you can add notifications to be shown on the device without the need for external services to send the push notifications.