简体   繁体   English

android 上的自动推送通知 Cordova

[英]Automatic push notification Cordova on android

I'm building a cordova app for android.我正在为 android 构建一个 cordova 应用程序。 I need a notification to the user when the database is updated even if they don't have the app open.我需要在数据库更新时通知用户,即使他们没有打开应用程序。 It's possible?这是可能的? How to do?怎么做?

Basically notifications provide short, timely information about events in your app while it's not in use.基本上,通知会在您的应用程序未使用时提供有关事件的简短、及时的信息。 For an introduction to how notifications appear on Android, see the Notifications Overview.有关如何在 Android 上显示通知的介绍,请参阅通知概述。 For sample code that uses notifications.The code on this uses the NotificationCompat APIs from the Android support library.对于使用通知的示例代码。此代码使用来自 Android 支持库的 NotificationCompat API。 These APIs allow you to add features available only on newer versions of Android while still providing compatibility back to Android 4.0 (API level 14).这些 API 允许您添加仅在较新版本的 Android 上可用的功能,同时仍提供与 Android 4.0(API 级别 14)的兼容性。 However, some new features such as the inline reply action result in a no-op on older versions.但是,一些新功能(例如内联回复操作)会导致旧版本无法操作。

Add the support library Although most projects created with Android Studio include the necessary dependencies to use NotificationCompat, you should verify that your module-level build.gradle file includes the following dependency:添加支持库 尽管使用 Android Studio 创建的大多数项目都包含使用 NotificationCompat 所需的依赖项,但您应该验证您的模块级 build.gradle 文件是否包含以下依赖项:

dependencies { implementation "com.android.support:support-c compat:28.0.0" }依赖项{实现“com.android.support:support-c compat:28.0.0”}

You can see more info here: https://developer.android.com/training/notify-user/channels您可以在此处查看更多信息: https://developer.android.com/training/notify-user/channels

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM