push notifications are working fine with actions buttons when app is in foreground and not showing action button when app is background (only notification are showing without action button)
only message no action buttons are there can somebody help me
@taikim8484 yes I have resolved after i did some changes in the manifest.xml and registered action
Manifest.xml
<application>
------
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
</application>
App.js
import { AppRegistry } from 'react-native';
import App from './App';
import backgroundPush from './src/backgroundPush';
AppRegistry.registerComponent('App', () => App);
AppRegistry.registerHeadlessTask('RNFirebaseBackgroundMessage', () => backgroundPush);
backgroundPush.js
import firebase from 'react-native-firebase';
export default async (message) => {
try {
const text = message.data.message;
const payload = JSON.parse(message.data.sendbird);
const localNotification = new firebase.notifications.Notification({
show_in_foreground: true
})
.android.setChannelId('com.myapp.default_channel_id')
.android.setPriority(firebase.notifications.Android.Priority.High)
.setNotificationId(message.messageId)
.setTitle('New message')
.setSubtitle(`Unread message: ${payload.unread_message_count}`)
.setBody(text)
.setData(payload);
const action = new firebase.notifications.Android.Action('Reply', 'ic_launcher', 'My Test Action');
// Add the action to the notification
localNotification.android.addAction(action);
return firebase.notifications().displayNotification(localNotification);
} catch (e) {
return Promise.resolve();
}
}