4

I am using FCM Data Messages for pushing Notifications to my Android App. So basically, my data payload will have the information like Notification Title, Message and Image URL. The Image URL will be different for each and every notification. After receiving Data Message from Firebase Messaging Service, I am posting the notification immediately and then doing an additional request for the Image(using AsyncTask). Once the fetch is successful I will update the Notification if it's still Active. Android Blog on how to notify users with FCM

Starting from Android 9, they have made some improvements to Battery-Saver Mode which results in more restrictions. So, On Battery-Saver Mode, the additional requests that I do for fetching Images are failing(SocketTimeOutException) continuously. I have tested this on Pixel and OnePlus 6 and is failing to load Images(during Battery-Saver Mode) on both the devices.

I tried doing the additional requests using the Work Manager/Job Scheduler and had no success.

And my App doesn't fall under acceptable use-cases for whitelisting(Battery Optimization Exceptions).

Is there any other way to successfully load images in the background for a Notification? Any help would be highly appreciated. Thanks.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • We're you able to find any solution? We are experiencing the same. We send notification to 180,000 users, but about 4,000 have a problem downloading the image (`java.net.UnknownHostException(Unable to resolve host "tca.b-cdn.net")`. – c0dehunter Feb 11 '21 at 15:44
  • @PrimožKralj and Pavan, Have you get any chance for a solution to this issue? I am also facing this issue. Let me know if any updates on this. – immodi Jun 28 '21 at 09:28
  • @immodi there is no known solution at this time. This seems to be caused by battery savers, preventing background networking. See also https://stackoverflow.com/questions/53593580/how-to-let-fcm-display-notification-even-when-app-is-in-foreground – c0dehunter Jun 29 '21 at 11:34
  • Sorry, posted the wrong link and can't edit anymore. This is the correct one: https://stackoverflow.com/questions/57725879/image-not-showing-in-push-notification – c0dehunter Jun 29 '21 at 11:41

0 Answers0