'Not receiving notification when it is sent while the application is killed/closed
My desired outcome is to be able to display a notification when one is received regardless of whether the app is in foreground/background/kill. I am currently able to receive the notification on my mobile application when it is in foreground/background and from there I will create a local notification.
However, when the application is killed, it returns an error saying D/FCMPlugin: Unable to send event due to unreachable bridge context.
My mobile application is developed using Ionic and the notification is sent through google fcm via php.
What am I doing wrongly?
"data" => [
"notification_id" => 101,
"item_id" => 1111111,
"ticket_classification" => "manual",
"routing_page"=>"TicketListPage",
"title" => "New Task" ,
"body" => "Hi " . $user->name . ",\nYou have a new " . $ticket_description ." task to work on." ,
"content-available"=> "1",
"force-start"=>"1"
],
"priority"=>"high"
Android FCM Plugin File
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// TODO(developer): Handle FCM messages here.
// If the application is in the foreground handle both data and notification messages here.
// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.
Log.d(TAG, "==> MyFirebaseMessagingService onMessageReceived");
if(remoteMessage.getNotification() != null){
Log.d(TAG, "\tNotification Title: " + remoteMessage.getNotification().getTitle());
Log.d(TAG, "\tNotification Message: " + remoteMessage.getNotification().getBody());
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("wasTapped", false);
if(remoteMessage.getNotification() != null){
data.put("title", remoteMessage.getNotification().getTitle());
data.put("body", remoteMessage.getNotification().getBody());
}
for (String key : remoteMessage.getData().keySet()) {
Object value = remoteMessage.getData().get(key);
Log.d(TAG, "\tKey: " + key + " Value: " + value);
data.put(key, value);
}
Log.d(TAG, "\tNotification Data: " + data.toString());
FCMPlugin.sendPushPayload(data);
}
// [END receive_message]
Log D Messages
D/FCMPlugin: ==> MyFirebaseMessagingService onMessageReceived
D/FCMPlugin: Key: content-available Value: 1
D/FCMPlugin: Key: force-start Value: 1
D/FCMPlugin: Key: notification_id Value: 101
D/FCMPlugin: Key: routing_page Value: TicketListPage
D/FCMPlugin: Key: ticket_classification Value: manual
D/FCMPlugin: Key: body Value: Hi Lengky,
You have a new A task to work on.
D/FCMPlugin: Key: title Value: New Task
D/FCMPlugin: Key: item_id Value: 1111111
D/FCMPlugin: Notification Data: {wasTapped=false, item_id=1111111, ticket_classification=manual, notification_id=101, routing_page=TicketListPage, content-available=1, body=Hi Lengky,
You have a new A task to work on., title=New Task, force-start=1}
D/FCMPlugin: ==> FCMPlugin sendPushPayload
D/FCMPlugin: payload: wasTapped => false
D/FCMPlugin: payload: item_id => 1111111
D/FCMPlugin: payload: ticket_classification => manual
D/FCMPlugin: payload: notification_id => 101
D/FCMPlugin: payload: routing_page => TicketListPage
D/FCMPlugin: payload: content-available => 1
D/FCMPlugin: payload: body => Hi Lengky,
You have a new A task to work on.
D/FCMPlugin: payload: title => New Task
D/FCMPlugin: payload: force-start => 1
D/FCMPlugin: Unable to send event due to unreachable bridge context
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|