Search code examples
androiddelphipush-notificationgoogle-cloud-messagingfiremonkey

How can I change the style of a GCM Push Notification


I'd like to change style of the GCM Push Notifications my app is receiving from the standard single line notification to a multi-line notification.

The solution from the Java world seems to be to set the style of the notification to BigTextStyle when it gets created.

I've found a solution for Local Notifications that involves hacking Androidapi.JNI.Support.pas and System.Android.Notification.pas so that NotificationBuilder has it's style set to BigTextStyle.

I don't see anything analogous to Notification Builder for GCM Push Notifications. What am I missing?

In this case the app is being built for Android using Firemonkey with Delphi 10 (Seattle).


Solution

  • So the answer is, if you want to do this you would have to alter the FMX.jar that's being deployed with the app.

    You'd have to alter the buildNotification method of the com.embarcadero.rtl.notifications.NotificationPublisher class.

    Source code for the FMX.jar is not distributed with RAD studio, etc. ; so your option is to decompile FMX.jar.

    This answer will give you a foothold on how to modify buildNotification. Effectively you'll add the following before the return.

    mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(myVeryLongGCMMessage));