【问题标题】:Xamarin Forms Local NotificationXamarin 形成本地通知
【发布时间】:2018-02-04 03:42:00
【问题描述】:

我是 xamarin 表单的新手,我想为跨平台制作本地通知。我使用由 edsnider ( Link - https://github.com/edsnider/LocalNotificationsPlugin ) 为 Xamarin 调用 Local Notifications Plugin 的插件,并按照文档要求我执行的操作。

我创建了一个按钮并将此代码用作其功能。这个想法是在单击按钮时收到通知

void Notify()
    {
        CrossLocalNotifications.Current.Show("Alert", "People spot", 10);
    }

当我按下我的 android 设备中的按钮时出现此错误。

System.NotImplementedException:方法或操作不是 实施。

希望尽快解决这个问题。谢谢你

【问题讨论】:

    标签: android xamarin.forms notifications localnotification


    【解决方案1】:

    Xamarin 插件实现通常特定于平台的功能。因此,您必须在所有项目中安装插件 - 所有平台项目和您的 PCL。您遇到的错误似乎是插件未正确安装在其中一个项目中。

    如果您已将其安装到所有项目中,请尝试从所有项目中卸载它,清理您的解决方案并再次从 NuGet 安装。

    另请注意,macOS 上的通知尚不支持。

    【讨论】:

      【解决方案2】:

      source codes,这里:

              private static ILocalNotifications CreateLocalNotificationsImplementation()
              {
      #if NETSTANDARD1_0
                  return null;
      #else
                  return new LocalNotificationsImplementation();
      #endif
              }
      

      如果你的.NET Standard是1.0,它会返回null,然后Current会返回throw NotImplementedInReferenceAssembly();,所以你会得到NotImplementedException

      请在 PCl 的属性文件中检查您的 .Net Framework 版本。

      如果是1.0,你需要改变它。

      如果不是 1.0,则异常意味着您的 Android 平台上没有 LocalNotificationsImplementation 实例,请按照 @Martin Zikmund 的建议进行操作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多