0

I'm using FCM to send notifications to my users, unfortunately some manufacturers interfere with notifications delivery, according to this article: https://onesignal.com/blog/manufacturers-interfere-with-reliable-notifications/

The problems comes up normally when users swipe off your app from the recent apps stack, since this cause a force stop on some devices.

Thinking of a solution, I've noticed that when app is opened after a notification is sent (but it's not shown by phone), the notification finally is displayed... so, my suggested approach it's to launch my app (in background) periodically to ensure that notifications are delivered to my users.

So.. my question: How can I launch my app on background programatically? Maybe posible with alarmManager, but not sure.

Some related info on this thread: Android app not receiving Firebase Notification when app is stopped from multi-task tray

Isaac Bosca
  • 1,588
  • 1
  • 15
  • 34

1 Answers1

0

For this case that you described, if app is forced stoped when user swipe it out from recent apps, then no process of it will work anymore until the next time that user opens the app. It's the behaviour of force closing and you can not start app in background if it is forced closed. The app will receive notification when it is opened by user because notifications has a lifetime on GCM which can be up to 4 weeks and by default is set to 4 weeks. So user will receive notification if opens his/her app sometime within this time to live interval.

For your case I suggest to show a guide to user at first run of application (specially for users of devices like Huawei, Asus and Xiaomi which have such settings as default) and encouraging them to exclude your app from those apps which are not allowed to work in background or access network in background. For example for some Huawei devices your app should be listed in Protected Apps and also be Networked Apps.

Akram
  • 2,158
  • 1
  • 17
  • 24
  • Thanks for your suggestion. I already show an initial guide to my users, but now I would like to improve my app. I'm thinking now on develop an SyncAdapter, hopefully this sync will work with stopped apps as well. – Isaac Bosca Feb 19 '18 at 08:08