简体   繁体   中英

Xamarin Forms Local Notification

i am new to xamarin form and i want to make local notification for cross platform. I use a plugin call Local Notifications Plugin for Xamarin by edsnider ( Link - https://github.com/edsnider/LocalNotificationsPlugin ) and follow as what the documentation ask me to do.

I create a button and use this code as it's function. The idea is to get a notification when the button is clicked

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

and i get this error when i press on the button in my android device.

System.NotImplementedException: The method or operation is not implemented.

Hope to solve this matter soon. Thank you

Xamarin Plugins implement functionality that is usually platform specific. Because of that you have to install the plugin in all your projects - all platform projects and your PCL. The error you are gettng seems that the plugin is not properly installed in one of the projects.

If you have installed it into all your projects, please try to uninstall it from all projects, clean your solution and install from NuGet again.

Also note that notifications on macOS are not yet supported.

In the source codes , here:

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

If your .NET Standard is 1.0, it will return null , and then Current will throw NotImplementedInReferenceAssembly(); , so you get NotImplementedException .

Please check your the version of .Net Framework in your PCl's Properties file.

If it is 1.0, you need change it.

If it is not 1.0, the exception means that there is no LocalNotificationsImplementation instance on your Android platform, do like @Martin Zikmund has suggested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM