rdelrosario / xamarin-plugins

Cross platform Xamarin & Windows plugins for PCLs
MIT License
179 stars 161 forks source link

Ignore Android Push Notification #15

Closed ghost closed 8 years ago

ghost commented 8 years ago

Is there a way to not create a notification if the user is currently in/using the app?

I know in iOS this seems to be the default behavior.

ghost commented 8 years ago

I found an easy way to get around this was to add just a couple lines of code to the Android project.

in IPushNotificationListener.cs added stub... bool IgnoreNotification()

in PushNotificationImplementation.cs adjusted the code to this.... if (!parameters.ContainsKey(PushNotificationKey.Silent) || !System.Boolean.Parse(parameters[PushNotificationKey.Silent].ToString())) { if(!CrossPushNotification.PushNotificationListener.IgnoreNotification()) CreateNotification(title, message, notifyId, tag); }

this allows us to control it in the PCL. Anyway to get these couple lines added to the project?

rdelrosario commented 8 years ago

Thanks for your suggestion. Try the newest NuGet package. Now should implement listener method ShouldShowNotification() to achieve this.

ghost commented 8 years ago

Thank you!