rdelrosario / xamarin-plugins

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

Seeing values for Notification header, title, body #24

Closed tonci77 closed 8 years ago

tonci77 commented 8 years ago

I have one question, a little bit of struggle regarding PCL method:

public class CrossPushNotificationListener : IPushNotificationListener { public void OnMessage (JObject values, DeviceType deviceType) { Debug.WriteLine ("Message Arrived"); }
....... I didn’t quite understood how to set (customize) “Notification” Title, Icon, Subject, Message text OnMessage event ?

Let’s say that receiving object values (JObject) contains strings/values for Notification Title, Subject, Message , so what would be the right aprouch in PCL project to applay these values before Notification is pop uped on user screen (both Android & iOs) ?

Thank's in advance for answer or suggestion.

rdelrosario commented 8 years ago

Hi

On the Android project you can set what keys on you MainActivity or Application class to display on the notification:

//The sets the key associated with the value will be used to show the
title for the notification
public static string NotificationContentTitleKey { get; set; }

//The sets the key associated with the value will be used to show the
text for the notification
public static string NotificationContentTextKey { get; set; }

//The sets the key associated with the root value will be used to show
the text inside it for the notification
public static string NotificationContentDataKey { get; set; }

//The sets the resource id for the icon will be used for the notification
public static int IconResource { get; set; }

//The sets the sound  uri will be used for the notification
public static Android.Net.Uri SoundUri { get; set; }

The key you set for the NotificationContentTitleKey will be the one displayed as the notification title. For example if you set key 'subject', then will look for the value associated to this key to display as the title.

The key you set for the NotificationContentTextKey will be the one displayed as the notification title. For example if you set key 'message', then will look for the value associated to this key to display as the message.

You can set the icon by setting the IconResource property to the desired drawable resource id.

On iOS is based as the Apple Standard since the Notifications values displayed is managed automatically based on the APS notification message.

Let me know if you got any other questions. Hope this helps!

rdelrosario commented 8 years ago

Btw, this is set using CrossPushNotification.NotificationContentTitleKey = "title" for example.

tonci77 commented 8 years ago

Thank s a lot.... I guess that I wasn’t reading with full attention that read-me file :-)

screen shot 2015-12-16 at 15 24 11

screen shot 2015-12-16 at 15 19 04

screenshot_2015-12-16-15-20-55

Ingenator commented 8 years ago

Hi guys! i'm wondering if there's a way to style the notification.

Is there a property or something to set notifications style as: big text, inbox and image?

Thanks for your time and what a nice plugin @rdelrosario !! you rock!

rdelrosario commented 8 years ago

Could you show an example of what you would like to achieve?

Ingenator commented 8 years ago

The examples are here they are for Android, actually the notification is recieved but the text is not visible because of it's length and it can't be dragged down to see all of its conent.

It shown like this: FIRST

And it could be converted to big text like this: Second

The other one is an inbox style:

Third

and when you drag it down is shown like this:

fourth

Is there a way to achieve that? Thanks again!

rdelrosario commented 8 years ago

Right no. there's no way using the plugin. But you could use other plugin to achieve this and turn off the show notifications in this plugin. But this surely looks like something we would like to add, so i will include this on the plugin whenever have some time.

Ingenator commented 8 years ago

Yeah that would be great! Looking forward for it! Thank you!