localnotificationsplugin icon indicating copy to clipboard operation
localnotificationsplugin copied to clipboard

Show large notification

Open sagarmp02 opened this issue 7 years ago • 7 comments

If this issue is for a new feature, please skip the "Bug" section and fill out the "Feature Request" section at the bottom.

Bug

Plugin Version:
Platform (e.g., Android v21):
Device/Hardware:

Expected behavior

Actual behavior

Steps to reproduce the behavior

Feature Request

Feature description:
I am using the following code in xamarin.forms page to send notification CrossLocalNotifications.Current.Show("title", "body"); it is working fine. But in the body, if I have long text how to show?. In a few places, I found that use the following code in the main activity of the Android project String longText = "..."; Notification noti = new Notification.Builder(this). .setStyle(new Notification.BigTextStyle().bigText(longText)) but NotificationBuilder class doesn't supports in xamarin.forms project. How should I set this from xamarin.forms project?. Please help me out

sagarmp02 avatar Mar 06 '19 12:03 sagarmp02

This whould be a Feature Request, were you want that the plugin is changing the Notification Style when your text is to long. This needs to be done directly in the plugin and no in your Xamarin.Forms project.

DoktorAerzt avatar Mar 06 '19 12:03 DoktorAerzt

Thank u for your reply @DoktorAerzt . Authors, please look into this request

sagarmp02 avatar Mar 06 '19 13:03 sagarmp02

The point is, how long needs the long text to be that the normal notification is to small and that you need BigTextStyle() ?

DoktorAerzt avatar Mar 06 '19 13:03 DoktorAerzt

@DoktorAerzt , maybe 4 or 5 lines I need to show in the notification. can i achieve my requirement by using BigTextStyle(). If yes how and where I need to set? my requirement like image

sagarmp02 avatar Mar 06 '19 13:03 sagarmp02

I never worked with BigTextStyle() so i don´t know if this will help you or if this is what you need. But you need to add a check at this line https://github.com/edsnider/localnotificationsplugin/blob/master/src/Plugin.LocalNotifications.Android/LocalNotificationsImplementation.cs#L33 and then if the body is greater/longer than let´s say 30 Chars then you need to use the BigTextStyle()

I don´t have the time to test this out and to make this changes.

After you make this changes you need to make an pull request.

DoktorAerzt avatar Mar 06 '19 13:03 DoktorAerzt

Hi @DoktorAerzt , following code will work. I am not understanding how to do pull request. can u add the following code at line number 33 please do help if(body.Length > 30) { builder.SetStyle(new NotificationCompat.BigTextStyle().BigText(body)); }

sagarmp02 avatar Mar 06 '19 14:03 sagarmp02

HI @edsnider please look into this just one line of code we need to change here builder.SetStyle(new Notification.BigTextStyle().BigText(body)); and update package from 23 to 28 please do consider this

sagarmp02 avatar Mar 08 '19 06:03 sagarmp02