According to Google documentation, developer can set a public version of a notification when visibility of notification is Private, using setPublicVersion() method. but this method does not exist in react-native-firebase API.
I had taken a look at type definition file and I figure out the function has been commented, don't know why
index.d.ts

Platform: Android
Development Operating System: Windows 10 x64
Build Tools: Android Studio 3.4.1, Android SDK 22 - 29
React Native version: 0.59.9
RNFirebase Version: 5.4.2
Firebase Module: notifications.android
Very strange. It appears to have been added commented out. It appears there is a JS + Android implementation though. You can easily uncomment this (and reliably maintain that change with patch-package). Could you try it and report back?
yes, sure.
I'll try that in the next few days and if everything was ok, I'll submit a PR
@mikehardy
I uncommented the line in the type definition file and use it in my code, but I'm facing with error setPublicVersion is not a function at runtime.
then I searched in react-native-firebase directory for the phrase setPublicVersion, the only files that contain such phrase are index.d.ts (as I mentioned before) and DisplayNotificationTask.java, in the second file the related part is commented too.

It seems the implementation has been left incomplete and has TODO for later implementation. because it doesn't pass a public version of the notification to function. can you help me fix this? how can I get
the object to pass it to the function? I'm a little bit confused with the android codes.
I could not find where the key-value pair of android bundle has been created to find out is really public notification object has been stored or not, but similar the other codes I rewrite the code section like below:

but still, I'm getting setPublicVersion is not a function error message at runtime.
I can't help fix it, sorry, but I can merge a PR if you get one working
It does seem to be all available just not hooked up. The javascript has it as well:
(virtualenv) mike@kunashir:~/work/react-random/react-native-firebase (v5-sdk-update) % grep -ri publicversion android/ ios/ src/ |grep -v build
android//src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: /* if (android.containsKey("publicVersion")) {
android//src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: nb = nb.setPublicVersion();
src//index.d.ts: //setPublicVersion(publicVersion: Notification): Notification
src//modules/notifications/types.js: // publicVersion: Notification,
src//modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
src//modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
src//modules/notifications/AndroidNotification.js: * @param publicVersion
src//modules/notifications/AndroidNotification.js: /* setPublicVersion(publicVersion: Notification): Notification {
src//modules/notifications/AndroidNotification.js: this._publicVersion = publicVersion;
src//modules/notifications/AndroidNotification.js: // publicVersion: this._publicVersion,
Also, I would follow an existing similar implementation, like subtitle or similar and just make it work the same. Right now in Java it's not actually fetching the value from the object that came over the bridge from javascript to put it into the Java notification yet
Do you know who is written these sections of code? maybe he/she can more help to understand why the functions have been commented and didn't hook up. I'm ready to help if I know how can I help.
You must be resourceful to successfully get a PR in and use the tools available - git website has a history and blame feature on the file.
That said, I checked already when you first posted this, and it was from years ago so may not be valid anymore. So I'm telling you explicitly how to do it:
Also, I would follow an existing similar implementation, like subtitle or similar and just make it work the same. Right now in Java it's not actually fetching the value from the object that came over the bridge from javascript to put it into the Java notification yet
Ok then, I'll work on it and if there is any problem, I will inform you. Just It may take time because I'm busy these days
@mikehardy I uncommented all codes related to publicVersion in the files you mentioned before. Now the error setPublicVersion is not a function has been gone, but another problem has been raised. in androidNotification.js file and within build() method the line publicVersion: this._publicVersion, causes error for me with a message that I don't really understand it.
build() {
// TODO: Validation of required fields
if (!this._channelId) {
throw new Error('AndroidNotification: Missing required `channelId` property');
} else if (!this._smallIcon) {
throw new Error('AndroidNotification: Missing required `smallIcon` property');
}
return {
actions: this._actions.map(action => action.build()),
autoCancel: this._autoCancel,
badgeIconType: this._badgeIconType,
bigPicture: this._bigPicture,
bigText: this._bigText,
category: this._category,
channelId: this._channelId,
clickAction: this._clickAction,
color: this._color,
colorized: this._colorized,
contentInfo: this._contentInfo,
defaults: this._defaults,
group: this._group,
groupAlertBehaviour: this._groupAlertBehaviour,
groupSummary: this._groupSummary,
largeIcon: this._largeIcon,
lights: this._lights,
localOnly: this._localOnly,
number: this._number,
ongoing: this._ongoing,
onlyAlertOnce: this._onlyAlertOnce,
people: this._people,
priority: this._priority,
progress: this._progress,
publicVersion: this._publicVersion, <-------- this line causes the error
remoteInputHistory: this._remoteInputHistory,
shortcutId: this._shortcutId,
showWhen: this._showWhen,
smallIcon: this._smallIcon,
sortKey: this._sortKey,
// TODO: style: Style,
tag: this._tag,
ticker: this._ticker,
timeoutAfter: this._timeoutAfter,
usesChronometer: this._usesChronometer,
vibrate: this._vibrate,
visibility: this._visibility,
when: this._when
};
}
The Error message
Malformed calls from JS: field sizes are different.

I can't help fix it, sorry, but I can merge a PR if you get one working
here鈥檚 an example of a thing that works (autoCancel) vs the property you want. Diagnose the differences and make them not different? Looks like something unexpected with regard to javascript<->android bridge object mapping
publicversion property
(virtualenv) mike@kunashir:~/work/react-random/react-native-firebase (dependency-updates) % grep -ri publicversion * ios/ android/ src/|grep -v build
android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: /* if (android.containsKey("publicVersion")) {
android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: nb = nb.setPublicVersion();
dist/index.d.ts: //setPublicVersion(publicVersion: Notification): Notification
dist/modules/notifications/AndroidNotification.js.flow: // _publicVersion: Notification;
dist/modules/notifications/AndroidNotification.js.flow: // _publicVersion: Notification;
dist/modules/notifications/AndroidNotification.js.flow: * @param publicVersion
dist/modules/notifications/AndroidNotification.js.flow: /* setPublicVersion(publicVersion: Notification): Notification {
dist/modules/notifications/AndroidNotification.js.flow: this._publicVersion = publicVersion;
dist/modules/notifications/AndroidNotification.js.flow: // publicVersion: this._publicVersion,
dist/modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
dist/modules/notifications/AndroidNotification.js: this._progress = data.progress; // _publicVersion: Notification;
dist/modules/notifications/AndroidNotification.js: * @param publicVersion
dist/modules/notifications/AndroidNotification.js: /* setPublicVersion(publicVersion: Notification): Notification {
dist/modules/notifications/AndroidNotification.js: this._publicVersion = publicVersion;
dist/modules/notifications/AndroidNotification.js: // publicVersion: this._publicVersion,
dist/modules/notifications/types.js.flow: // publicVersion: Notification,
src/index.d.ts: //setPublicVersion(publicVersion: Notification): Notification
src/modules/notifications/types.js: // publicVersion: Notification,
src/modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
src/modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
src/modules/notifications/AndroidNotification.js: * @param publicVersion
src/modules/notifications/AndroidNotification.js: /* setPublicVersion(publicVersion: Notification): Notification {
src/modules/notifications/AndroidNotification.js: this._publicVersion = publicVersion;
src/modules/notifications/AndroidNotification.js: // publicVersion: this._publicVersion,
android//src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: /* if (android.containsKey("publicVersion")) {
android//src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: nb = nb.setPublicVersion();
src//index.d.ts: //setPublicVersion(publicVersion: Notification): Notification
src//modules/notifications/types.js: // publicVersion: Notification,
src//modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
src//modules/notifications/AndroidNotification.js: // _publicVersion: Notification;
src//modules/notifications/AndroidNotification.js: * @param publicVersion
src//modules/notifications/AndroidNotification.js: /* setPublicVersion(publicVersion: Notification): Notification {
src//modules/notifications/AndroidNotification.js: this._publicVersion = publicVersion;
src//modules/notifications/AndroidNotification.js: // publicVersion: this._publicVersion,
autocancel property
(virtualenv) mike@kunashir:~/work/react-random/react-native-firebase (dependency-updates) % grep -ri autocancel * ios/ android/ src/|grep -v build
android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: if (android.containsKey("autoCancel")) {
android/src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: nb = nb.setAutoCancel(android.getBoolean("autoCancel"));
dist/index.d.ts: autoCancel?: boolean;
dist/index.d.ts: setAutoCancel(autoCancel: boolean): Notification;
dist/modules/notifications/AndroidNotification.js.flow: _autoCancel: boolean | void;
dist/modules/notifications/AndroidNotification.js.flow: this._autoCancel = data.autoCancel;
dist/modules/notifications/AndroidNotification.js.flow: get autoCancel(): ?boolean {
dist/modules/notifications/AndroidNotification.js.flow: return this._autoCancel;
dist/modules/notifications/AndroidNotification.js.flow: * @param autoCancel
dist/modules/notifications/AndroidNotification.js.flow: setAutoCancel(autoCancel: boolean): Notification {
dist/modules/notifications/AndroidNotification.js.flow: this._autoCancel = autoCancel;
dist/modules/notifications/AndroidNotification.js.flow: autoCancel: this._autoCancel,
dist/modules/notifications/AndroidNotification.js: this._autoCancel = data.autoCancel;
dist/modules/notifications/AndroidNotification.js: get autoCancel() {
dist/modules/notifications/AndroidNotification.js: return this._autoCancel;
dist/modules/notifications/AndroidNotification.js: * @param autoCancel
dist/modules/notifications/AndroidNotification.js: setAutoCancel(autoCancel) {
dist/modules/notifications/AndroidNotification.js: this._autoCancel = autoCancel;
dist/modules/notifications/AndroidNotification.js: autoCancel: this._autoCancel,
dist/modules/notifications/types.js.flow: autoCancel?: boolean,
src/index.d.ts: autoCancel?: boolean;
src/index.d.ts: setAutoCancel(autoCancel: boolean): Notification;
src/modules/notifications/types.js: autoCancel?: boolean,
src/modules/notifications/AndroidNotification.js: _autoCancel: boolean | void;
src/modules/notifications/AndroidNotification.js: this._autoCancel = data.autoCancel;
src/modules/notifications/AndroidNotification.js: get autoCancel(): ?boolean {
src/modules/notifications/AndroidNotification.js: return this._autoCancel;
src/modules/notifications/AndroidNotification.js: * @param autoCancel
src/modules/notifications/AndroidNotification.js: setAutoCancel(autoCancel: boolean): Notification {
src/modules/notifications/AndroidNotification.js: this._autoCancel = autoCancel;
src/modules/notifications/AndroidNotification.js: autoCancel: this._autoCancel,
android//src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: if (android.containsKey("autoCancel")) {
android//src/main/java/io/invertase/firebase/notifications/DisplayNotificationTask.java: nb = nb.setAutoCancel(android.getBoolean("autoCancel"));
src//index.d.ts: autoCancel?: boolean;
src//index.d.ts: setAutoCancel(autoCancel: boolean): Notification;
src//modules/notifications/types.js: autoCancel?: boolean,
src//modules/notifications/AndroidNotification.js: _autoCancel: boolean | void;
src//modules/notifications/AndroidNotification.js: this._autoCancel = data.autoCancel;
src//modules/notifications/AndroidNotification.js: get autoCancel(): ?boolean {
src//modules/notifications/AndroidNotification.js: return this._autoCancel;
src//modules/notifications/AndroidNotification.js: * @param autoCancel
src//modules/notifications/AndroidNotification.js: setAutoCancel(autoCancel: boolean): Notification {
src//modules/notifications/AndroidNotification.js: this._autoCancel = autoCancel;
src//modules/notifications/AndroidNotification.js: autoCancel: this._autoCancel,
(virtualenv) mike@kunashir:~/work/react-random/react-native-firebase (dependency-updates) %
@mikehardy
I understood you can't help with this, please mention any other developer that you think can help me.
I think, one thing that causes the error may the type of publicVersion in method signature of setPublicVersion. already it is Notification but actually it must be AndroidNotification because it is a method for android only. on the other hand, even changing the types in signatures, I can't create an AndroidNotification Object because it doesn't have a constructor and also even I add it, AndroidNotification doesn't has some necessary fields for android notifications like title and body, because they moved to Notification interface to be common between android and IOS notification objects.
This problem needs one of the active developers of this repository to be solved, because it may have some hidden side effects if I change the structure of interfaces.
I鈥檒l tag it for v6 and @Salakar - I believe he is working on notifications now
There is no released version for cloud messeging and notification yet, so I can't migrate to v6, is that right?
@SaeedZhiany that is true, but notifications is in progress literally this moment, with notification trialing. Which is to say, it should be shortly
Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?
This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.
Closing this issue after a prolonged period of inactivity. If this is still present in the latest release, please feel free to create a new issue with up-to-date information.