【发布时间】:2017-04-06 16:25:20
【问题描述】:
我正在使用 django-push-notifications 通过 FCM 从我的服务器 (Django) 发送通知:
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")
我可以使用cordova-plugin-fcm 在移动应用程序(ionic 1.3.3、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);
});
问题是栏没有显示通知,没有振动,没有声音,...我已经使用 extra 参数修改了devices.send_message 选项,但没有任何反应。
按照我修改清单的 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>
是应用配置有问题吗?以我从服务器发送通知的方式?还是只是我使用的插件没有在通知栏中显示任何内容?
...我应该使用收到的数据手动创建通知吗?
【问题讨论】:
-
尝试重新安装您的应用。或清除数据。
-
我每次在设备中测试应用程序时都使用命令“ionic run android -c -s”,因此重新安装了应用程序
标签: android angularjs django django-push-notifications cordova-plugin-fcm