edsnider / localnotificationsplugin

Local Notifications Plugin for Xamarin and Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show large notification

sagarmp02 opened this issue · 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

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.

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

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

@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

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.

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));
}

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