cordova-plugin-firebasex icon indicating copy to clipboard operation
cordova-plugin-firebasex copied to clipboard

java.lang.NullPointerException when notification recieved when app in the foreground

Open mleech opened this issue 3 years ago • 8 comments

Bug report

CHECKLIST

  • [X] I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
  • [X] I have checked that no similar issues (open or closed) already exist.

Current behavior:

When app is in the foreground onMessageReceived is not triggered. The following line appears in the console output:

[ng] [console.error]: "FirebasePlugin[native]: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.net.Uri.toString()' on a null object reference"

I believe the source of the error is the following line (152):

image = notification.getImageUrl().toString();

in FirebasePluginMessagingService.java https://github.com/dpa99c/cordova-plugin-firebasex/blob/ddbaccc45c3da39e5b4a6fb8255935d372cfe275/src/android/FirebasePluginMessagingService.java#L152

notification.getImageUrl() can return null (see: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/RemoteMessage.Notification#public-uri-getimageurl), but this code doesn't handle that case.

Expected behavior:

onMessageRecieved should trigger without error

mleech avatar Feb 14 '22 07:02 mleech

Looks like this bug was introduced by PR #667

@ollm as PR author, are you able to submit a PR to fix this bug?

dpa99c avatar Feb 14 '22 08:02 dpa99c

Fixed by #709 which is merged and will be published with next release

dpa99c avatar Feb 14 '22 12:02 dpa99c

Wow, thank you and @rokkreslincom for the quick turnaround on this

mleech avatar Feb 14 '22 15:02 mleech

Fixed by #709 which is merged and will be published with next release @dpa99c

When is that released? Kind og breaks our code right now.

renemadsen avatar Mar 02 '22 16:03 renemadsen

When is that released? Kind og breaks our code right now.

@renemadsen I suggest you install this plugin at the specific commit that includes this fix, then subscribe to this issue to see when it's closed, or even subscribe to the repo as a whole to see when a new update is released.

I've installed this in my project using the following:

cordova plugin add https://github.com/dpa99c/cordova-plugin-firebasex.git#751ba5a35fe7461731cde6a1ea5fd1b973941572

obviously appending any --variable arguments your own project requires..

ZaLiTHkA avatar Mar 07 '22 11:03 ZaLiTHkA

Well, its now been nearly 3 months that the 14.0.0 was released which is broken for Android but works in IOS. So for Android I need either the specific commit OR use the previous 13.0.0 version and of course those both do NOT work in IOS because of issues with the LD_RUN... etc. The set of steps to take in IOS is also pretty much a nightmare.

Let me paint a picture of the only set of steps that currently works for IOS if the last one you worked on was Android:

  • remove [email protected] from package.json (that works in Android)
  • comment all firebasex imports and code in src
  • delete package-lock.json and node_modules
  • do fresh npm install
  • ionic cordova platform add ios
  • ionic cordova build ios --prod
  • open .xcworkspace
  • set dev team + goto build settings -> signing -> Code signing identify and choose IOS developer
  • build settings --> linking --> Runpath Search paths and add the $(inherited) to both debug and release items in this category
  • build to simulator
  • close xcode/simulator
  • now we can add the plugin back and uncomment all the code in .src
  • back to xcode to test or release the code.

And of course the other way round if you then need to do an Android release. Love your plugin but feel my pain ;-)

Could we get an ETA on a next release please?

quadrofolio avatar Apr 26 '22 21:04 quadrofolio

This is creating some major issues for me as well, trying to maintain simultaneous Android and iOS releases for my app. Not trying to be negative, just a bit puzzled by the lack of a new version release here.

cinnamon-doge avatar May 04 '22 09:05 cinnamon-doge

Well, its now been nearly 3 months that the 14.0.0 was released which is broken for Android but works in IOS. So for Android I need either the specific commit OR use the previous 13.0.0 version and of course those both do NOT work in IOS because of issues with the LD_RUN... etc. The set of steps to take in IOS is also pretty much a nightmare.

Let me paint a picture of the only set of steps that currently works for IOS if the last one you worked on was Android:

* remove [email protected] from package.json (that works in Android)

* comment all firebasex imports and code in src

* delete package-lock.json and node_modules

* do fresh npm install

* ionic cordova platform add ios

* ionic cordova build ios --prod

* open .xcworkspace

* set dev team + goto build settings -> signing -> Code signing identify and choose IOS developer

* build settings --> linking --> Runpath Search paths and add the $(inherited) to both debug and release items in this category

* build to simulator

* close xcode/simulator

* now we can add the plugin back and uncomment all the code in .src

* back to xcode to test or release the code.

And of course the other way round if you then need to do an Android release. Love your plugin but feel my pain ;-)

Could we get an ETA on a next release please?

This is creating some major issues for me as well, trying to maintain simultaneous Android and iOS releases for my app. Not trying to be negative, just a bit puzzled by the lack of a new version release here.

The issue is fixed for me by the 14.1 release - I no longer need to juggle the version for Android and iOS.

cinnamon-doge avatar Jun 15 '22 12:06 cinnamon-doge