2

I need to use toasts on Xamarin.Forms. I found Toasts.Forms.Plugin but its not for WP8.1

I was facing a lot of performance issues on WinPhone8 so I created WP8.1 project.

What do I need to do to make it work on WP8.1? Can someone help me figure out the changes I need to do?

Edit: I get the following error when I'm adding the Toasts.Forms.Plugin package

install-package : Could not install package 'Toasts.Forms.Plugin 1.0.6.18'. You are trying to install this package into a project that 
targets 'WindowsPhoneApp,Version=v8.1', but the package does not contain any assembly references or content files that are compatible with 
that framework. For more information, contact the package author.
At line:1 char:1
+ install-package Toasts.Forms.Plugin
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
Dushyant Bangal
  • 6,048
  • 8
  • 48
  • 80

2 Answers2

1

Toasts.Forms.Plugin is actually available for WP8.1, if your using portable projects. I'm using it in one of my Xamarin Forms projects with WP8.1

Just install the package with Package Manager Console, and make sure you're selecting your WP8.1-project as the "default project":

install-package Toasts.Forms.Plugin

It should result in something like the following element added to your packages.config in your WP8.1-project.

<package id="Toasts.Forms.Plugin" version="1.0.6.18" targetFramework="wp81" />

To make it work with the other Toasts.Forms.Plugins you can use the DependencyService like so:

DependencyService.Get<IToastNotificator>()

If you run into problems you can use a shared library, and let each platform inject it's own dependencies, like such:

public class ServiceRepositoryBase
{
    protected static IToastNotificator ToastNotificator;
    public static void Init(IToastNotificator toastNotificator)
    {
        ToastNotificator = toastNotificator;
    }
    // Other code here...
}

And in your MainPage.xaml.cs:

ServiceRepositoryBase.Init(DependencyService.Get<IToastNotificator>());
smoksnes
  • 10,509
  • 4
  • 49
  • 74
0

That's because that plugin, at the moment, only provides libraries for WinPhone Silverlight (wp8). You're probably using WinRT instead (wpa81) for your project, and there are no specific libraries for this target in the plugin. Only thing you can do to use it, is to change your WinPhone project to a Silverlight 8.1 project.

Supported targets can be figured out from the .nupkg file https://github.com/EgorBo/Toasts.Forms.Plugin/blob/master/.nuget/Toasts.Forms.Plugin.1.0.6.18.nupkg

Massimo Prota
  • 1,226
  • 7
  • 14
  • Yes, I know its not supported yet; I was planning in making some changes and adding WP8.1 project to it; Because I didnt see a lot of code, in WP8 project. I've already done a lot of things in the project, dont want to add silverlight and recheck everything. – Dushyant Bangal Sep 04 '15 at 10:54
  • I added the WP8.1 project as per Xamarin's guide. – Dushyant Bangal Sep 04 '15 at 10:55
  • ok, WinRT support for Xamarin Forms is now official, but not all the plugins are also providing libraries for WinRT (wpa81) yet. This is your case – Massimo Prota Sep 04 '15 at 11:26