已收到通知,但没有在通知栏
显示图标,我使用django-push-notifications
我的服务器(Django的)通过FCM发送通知:已收到通知,但没有在通知栏
from push_notifications.models import GCMDevice
agents_user_ids = [agent.user.id for agent in task.agents.all()]
devices = GCMDevice.objects.filter(user_id__in=agents_user_ids)
devices.send_message("You have a new task", title="New Task")
我能够在移动应用中接收数据(离子1.3。 3,使用cordova-plugin-fcm
angularjs 1.5.3):
FCMPlugin.onNotification((data) => {
alert(JSON.stringify(data));
}, function(msg){
console.log("FCM Notification callback registered.");
}, function(err){
console.log("FCM Notification callback registration error: " + err);
});
的问题是没有通知显示在酒吧,无振动,无声音,......我已经使用修改devices.send_message
选项额外 ARG但没有任何反应。
继FCM文件我修改清单加入:
<application>
...
<service android:name="com.gae.scaffolder.plugin.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.gae.scaffolder.plugin.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/ic_stat_ic_notification" />
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/colorAccent" />
</application>
是它的应用程序配置有问题?与我从服务器发送通知的方式?或者它只是我使用的插件不显示通知栏中的任何内容?
...我应该使用收到的数据手动创建通知吗?接受它,当
可能有两个原因
是您的应用程序在后台?检查https://firebase.google.com/docs/cloud-messaging/android/receive
也基于上述链接,只有在两种情况下,您的设备会自动显示您的消息作为通知。该消息可能会传送到您的应用程序,然后您的应用程序需要将通知推送到设备。检查https://developer.android.com/training/notify-user/build-notification.html
首先,我试图使它在前台应用程序中工作。在您的链接之后,我将元数据包含在我的Manifest的应用程序标记中,但没有结果:( – juankysmith
@juankysmith在第一个链接中提到,当您的应用程序位于前台时,消息将直接传递给您的onMessageReceived()方法你的类扩展了FirebaseMessagingService,你已经处理了这个消息,并且使用第二个链接在你自己的代码中建立了一个通知 换句话说,当使用FCM和app是前台时,NO通知会自动显示。 – katie
尝试重新安装您的应用程序或清除数据。 –
我每次使用命令“ionic run android -c -s”来测试设备中的应用程序,因此该应用程序被重新安装。 – juankysmith