- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我得到了以下用于在工业应用程序中显示警报/错误的 Ionic 代码片段:
showError(message: string) {
let toast = this.toastController.create({
message: message,
position: 'top',
duration: 5000,
cssClass: 'danger',
showCloseButton: true
});
toast.present();
}
应用程序每次检测到连接问题时都会触发错误消息,这也大致是在 5 秒计时器上。
如果更改此代码的时间,多次调用此方法将导致 2 条或更多错误消息相互叠加显示。我能以某种方式检测到已经显示了 toast 吗?此外,5000 毫秒计时器将不再是必需的,我可以在重新建立连接时再次删除错误消息。
谢谢 BR Florian
最佳答案
您可以将 Toast 对象存储在函数外部的变量中,并在显示下一个 toast 之前调用 dismiss() 方法:
import { ToastController } from '@ionic/angular';
toast: HTMLIonToastElement;
showError(message: string) {
try {
this.toast.dismiss();
} catch(e) {}
this.toast = this.toastController.create({
message: message,
position: 'top',
duration: 5000,
color: 'danger',
showCloseButton: true
});
toast.present();
}
import { ToastController, Toast } from 'ionic-angular';
toast: Toast;
showError(message: string) {
try {
this.toast.dismiss();
} catch(e) {}
this.toast = this.toastController.create({
message: message,
position: 'top',
duration: 5000,
cssClass: 'danger',
showCloseButton: true
});
toast.present();
}
关于cordova - ionic : How to not stack multiple toast notifications?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42133217/
我遵循了提供的文档 here并且可以在 Android N 及更高版本上成功创建通知组。然而,我遇到的问题是 Android Oreo,每个发布到群组的通知都会为群组播放声音。 这很烦人,因为我只想播
单点触控 当应用程序返回前台时,我需要激活的 ViewController 来了解这一点。 是否有一个事件或覆盖我可以用来确定 View 被带到前台。 我确实找到了“WillEnterForegrou
我正在尝试在我的项目中创建一个通知系统。 这些是我已经完成的步骤: 1-php artisan notifications:table 2-php artisan migrate 3-php arti
我想知道如何批量发送推送通知。我们从以下3个主要模式来看问题: 一次API调用->一条消息->发送给指定用户 一次 API 调用 -> 一条消息 -> 传递给许多不同的用户(由 id 指定) 一个 A
我想在用户点击保存或删除按钮时显示通知。 Here is what i use for it.(Kendo notification) 我认为我的 CSS 部分有问题,我更改了很多东西但我仍然在原地。
在我的测试代码中,我使用了 notification.flags |= Notification.DEFAULT_SOUND; notification.flags |= No
当 Redis Sentinel 通知事件时,它不会提供 Redis 主节点的名称。 配置摘录: # sentinel notification-script # # Call the speci
Microsoft Exchange 引入了流通知作为 Exchange 2010 中拉/推通知的替代方法。有关流的基本介绍可以在此 msdn article 上找到。和 blog 但是,我无法弄清楚
我在理解WebExtensions notification.onClicked事件的文档时遇到问题。 最终,我要在单击通知时将通知文本复制到剪贴板。但是,现在我在理解回调内容或必须在其中插入noti
我即将实现ionic-native Push Notifications .这可以在浏览器中运行吗?还是我需要安装 iOS/Android 模拟器? 最佳答案 除非您使用 Phonegap 推送服务器
Safari 12.1 是否支持服务 worker PWA 推送通知?我试过这个 demo在 iOS 上,但它仍然不适合我。 有机会得到它们吗?谢谢。 最佳答案 目前没有关于此功能的通信...Appl
我遇到了一个奇怪的错误。一段时间以来,这种崩溃一直在我的 Fabric 中出现 致命异常:android.app.RemoteServiceException:startForeground 的错误通
我正在使用 Google Cloud Messaging 在 iOS 应用中接收推送通知。为了了解该系统的可靠性,我进行了两项测试。1.当应用程序处于前台时接收通知 下面称为curl 12. 当应用程
String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationM
我想在我的 Android 应用程序中使用 Notification,但我不知道 Android 中的 Notification 和 Push Notification 有什么区别. 我在网上搜索了这
我有两个模型之间的多对多关系: 用户 namespace App\Models; class User extends Model { use HasApiTokens, Notifiable
我在 App Store 中有一个 iPad 应用程序,其逻辑主要依赖于本地通知。换句话说,应用程序内部发生的很多事情都是由委托(delegate)方法应用程序 didReceiveLocalNoti
我知道如何制作每天在特定时间触发的本地通知。但是如何为每个通知更改 UNMutableNotificationContent.Body? 现在它只是一遍又一遍地显示相同的文本。 我正在为 iOS 10
请问,是否可以在没有用户 ID 的情况下发送推送通知?假设我们想向所有下载了我们应用程序的用户发送推送消息。或者出于安全原因,用户 ID 不能存储在数据库中(或在应用程序中使用)。 最佳答案 不管怎样
我在使用 Twilio notify 发送通知时遇到异常。 当我在使用相同的 Twilio NotificationCreator bean 发送 SMS 后发送通知时,如果我发送通知而不发送 SMS
我是一名优秀的程序员,十分优秀!