如何通过二维码发送 android 推送通知?
How can I send android push notifications through a QR Code?
我正在开发一个 android 应用程序并使用 Zxing QR 码生成器。我想知道二维码的结果是否可以是 android 推送通知。如果是这样,那该怎么做?谢谢
当QR码同时扫描时,您需要在FCM令牌前面制作一个QR码或ID之类的数据库如果记录存在,请拨打一个服务电话,然后将通知发送到特定设备。
你要的是在扫描二维码后立即进行本地通知,并将扫描结果的内容显示为通知。另一方面,推送通知是从服务器发送的。因此两者不同
您可以使用 NotificationCompat.Builder
进行本地通知
生成通知的简单方法是 -
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!");
// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
您还可以通过以下链接了解如何生成不同类型的通知 -
我正在开发一个 android 应用程序并使用 Zxing QR 码生成器。我想知道二维码的结果是否可以是 android 推送通知。如果是这样,那该怎么做?谢谢
当QR码同时扫描时,您需要在FCM令牌前面制作一个QR码或ID之类的数据库如果记录存在,请拨打一个服务电话,然后将通知发送到特定设备。
你要的是在扫描二维码后立即进行本地通知,并将扫描结果的内容显示为通知。另一方面,推送通知是从服务器发送的。因此两者不同
您可以使用 NotificationCompat.Builder
生成通知的简单方法是 -
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!");
// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
您还可以通过以下链接了解如何生成不同类型的通知 -