GCM Android通知未扩展

GCM Android通知未扩展,android,notifications,google-cloud-messaging,push,Android,Notifications,Google Cloud Messaging,Push,我已经为iOS和android实现了GCM,这一部分似乎运行良好。我的问题是,当通知中的文本超过一行时,我在Android上的通知无法扩展。我一直在寻找建议使用BigView调用通知的解决方案。我的通知是通过GCM直接发送到设备的,我不会在两者之间进行编辑。我不知道如何处理这个问题 我应该只是从通知中获取数据部分并在本地调用通知来解决这个问题,还是可以在从服务器发送GCM时使用一些东西 编辑: 我得到了扩展通知工作,但它仍然没有解决我的问题,因为它显示重复的通知。一个来自GCM,另一个来自本地调

我已经为iOS和android实现了GCM,这一部分似乎运行良好。我的问题是,当通知中的文本超过一行时,我在Android上的通知无法扩展。我一直在寻找建议使用BigView调用通知的解决方案。我的通知是通过GCM直接发送到设备的,我不会在两者之间进行编辑。我不知道如何处理这个问题

我应该只是从通知中获取数据部分并在本地调用通知来解决这个问题,还是可以在从服务器发送GCM时使用一些东西

编辑:
我得到了扩展通知工作,但它仍然没有解决我的问题,因为它显示重复的通知。一个来自GCM,另一个来自本地调用的通知。我尝试将标记从GCM通知应用到本地通知,但无法解决问题。

尝试在通知生成器中设置此样式:

.setStyle(new NotificationCompat.BigTextStyle().bigText("your_message_here"))

尝试在通知生成器中设置此样式:

.setStyle(new NotificationCompat.BigTextStyle().bigText("your_message_here"))

为通知创建通知布局。然后在textview中设置“lines=2”或使用“multiline”

自定义通知.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/layout"
 android:layout_width="fill_parent"
  android:layout_height="fill_parent"
    android:padding="10dp" >
    <ImageView android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_marginRight="10dp" />
    <TextView android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/image"
    style="Custom Notification Title" />
 <TextView android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/image"
    android:layout_below="@id/title"
    style="Custom Notification Text" />
</RelativeLayout>

为通知创建通知布局。然后在textview中设置“lines=2”或使用“multiline”

自定义通知.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/layout"
 android:layout_width="fill_parent"
  android:layout_height="fill_parent"
    android:padding="10dp" >
    <ImageView android:id="@+id/image"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_alignParentLeft="true"
    android:layout_marginRight="10dp" />
    <TextView android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/image"
    style="Custom Notification Title" />
 <TextView android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/image"
    android:layout_below="@id/title"
    style="Custom Notification Text" />
</RelativeLayout>

我使用的是直接GCM通知。我应该重写GcmReceiver类并自己生成通知吗?是的。。这将是构建我们自己的自定义通知的更好方法。。我建议您使用Firebase云消息传递。它可以工作,但GCM会显示重复的通知。我想做的是用本地通知覆盖GCM通知,即使我将标记从GCM通知应用到本地通知。我使用的是直接GCM通知。我应该重写GcmReceiver类并自己生成通知吗?是的。。这将是构建我们自己的自定义通知的更好方法。。我建议您使用Firebase云消息传递。它可以工作,但GCM会显示重复的通知。我想做的是用本地通知覆盖GCM通知,即使我将标记从GCM通知应用到本地通知。创建通知时使用什么并不重要。您需要多行文本。所以只需在textview属性中进行更改。根据你的需要。这似乎更适合我想做的事。没有捷径可走。如果您想定制android操作系统的内置通知。然后你必须创建你自己的。你用什么来创建通知并不重要。您需要多行文本。所以只需在textview属性中进行更改。根据你的需要。这似乎更适合我想做的事。没有捷径可走。如果您想定制android操作系统的内置通知。然后你必须创造你自己的。