I am trying to implement a event handler to see if a custom data attribute is present and if so remove some app data. The issue is now that no due to the event delegate i cannot show the notifications that do not match the custom data value.
I need to display the push notification if it doesn't have the custom data key. How can i do this in Xamarin forms?
private void SetupPushNotificationHandle()
{
// This should come before AppCenter.Start() is called
// Avoid duplicate event registration:
if (!AppCenter.Configured)
{
Push.PushNotificationReceived += (sender, e) =>
{
OceanBusiness business = CoreDependencyService.GetBusinessLayer<OceanBusiness>();
// If there is custom data associated with the notification,
// print the entries
if (e.CustomData != null)
{
foreach (var key in e.CustomData.Keys)
{
switch (key)
{
case CoreSettings.ClearData:
{
if(key.ToLower() == "true")
business.RemoveData();
break;
}
}
}
}
};
}
I have seen how to do this in Xamarin.Android but not in Xamarin.iOS. As such answers that do not show how to do both will not address this question.