I am sending a Notification from my server (Django) using django-push-notifications
through 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")
I am able to receive the data in a mobile app (ionic 1.3.3, angularjs 1.5.3) using cordova-plugin-fcm
:
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);
});
The problem is no notification is displayed in the bar, no vibration, no sound, ... I already modified the devices.send_message
options using extra argument but nothing happens.
Following FCM documentation I modified manifest by adding:
<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>
Is it a problem with app configuration? with the way I send the notification from server? or it is just the plugins I am using don't display anything in the notifications bar?
... Shall I create the notification manually using the received data?