I try to realize a shared project with Xamarin Forms for Android, ios and WinPhone. I want to use notifications and I followed this sample (https://github.com/edsnider/Xamarin.Plugins/tree/master/Notifier) and was able to create a local notification in Android. But i still do not understand how to work with that like Android application. Open a page or check if the page is already active or abort a broadcast for all platforms. Any links that could help me? Am I correct that it only works with an Interface that i have to implement in each platform or does exist any other solution?
My basic problem is that I get messages from the xmpp-protocol and want to send message notifications to the user or update the ui if open...
Thanks for your help...
You do not have to add any interfaces to your platform projects, Just intall nuget package to both projects Android/IOS.
on IOS you should add:
to your method:
in AppDelegate:
Then in your shared project you call:
As of replacing your current page, you do not have to do anything, Xamarin Forms will handle that for you.
Also on android, you can controll, you application relaunch behavior by setting LaunchMode of your MainActivity:
Example:
To read more about LauchModes on Android, please read:
https://developer.android.com/guide/components/tasks-and-back-stack.html
And check additionl activity flags:
Currently this plugin does not allow to catch any notification inside app. But you can do this, by using platform specific functionality
IOS: Please refer to https://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/ios/remote_notifications_in_ios/
Android: After reading through source of this plugin, i've discovered, that youcan check Bundle in your on create method for key ScheduledAlarmHandler.LocalNotificationKey
Also you can try to use BroadcastReceiver class; https://developer.xamarin.com/api/type/Android.Content.BroadcastReceiver/