0
我在项目中使用EgorBo的Toasts.Forms.Plugin,它工作正常。我将它添加到一个新项目中,但我找不到ToastNotification或IToastNotification并且不会出现吐司。Xamarin表格:Toasts.Forms.Plugin错误
我Xamarin.Forms版本2.3.2.127和你的组件是1.0.1
我试图在iOS的AppDelegate.cs
DependencyService.Register<Plugin.Toasts.CrossToasts>();
Plugin.Toasts.ToastsImplementation.Init();
但显然它不添加此代码”工作。我试图改变我的静态方法,但IToasts它不起作用。
public static async Task ShowToast(ToastNotificationType type,
string title, string description) {
var notificator = DependencyService.Get<Plugin.Toasts.Abstractions.IToasts>();
if (notificator != null) {
bool tapped = await notificator.Notify(type, title, description,
TimeSpan.FromSeconds(2));
}
}
原始代码AppDelegate.cs
DependencyService.Register<ToastNotificatorImplementation>();
ToastNotificatorImplementation.Init();
原始代码在我的课
public static async void ShowToast(ToastNotificationType type, string title,
string description) {
var notificator = DependencyService.Get<IToastNotificator>();
if (notificator != null) {
bool tapped = await notificator.Notify(type, title, description,
TimeSpan.FromSeconds(2));
}
}
预先感谢您。