Reputation: 91
i'm creating one application where i'm using fcm. it's work fine on some device but in some device like OPPO, RED-MI 5 PRO message not receiving after app killed. so what i have to do make sure message received every time on every device.
Upvotes: 3
Views: 182
Reputation: 91
so with Chinese Devices there are lot of issues with handling app services in background.
It works fine in stock roms but when it comes to customized ROM then there are lot of issues because the chinese devices restricts apps to be used in background.
So, apps like Whatsapp,Facebook or any big firm apps are whitelisted by these custom ROMs. But for new apps you can make the app accessible in background. When you swipe the app from app tray it considers it as Force Quit. It won't even run any Jobs, Task Scheduled.
What you can do is, Ask Used to Manual white list the app using,
val intent = Intent()
val manufacturer = android.os.Build.MANUFACTURER
when {
"xiaomi".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity")
"oppo".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity")
"vivo".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")
"Letv".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity")
"Honor".equals(manufacturer, ignoreCase = true) -> intent.component = ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity")
}
val list = applicationContext.packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)
if (list.size > 0) {
applicationContext.startActivity(intent)
}
With tech savvy users it might even work but don’t be surprised if you don’t get much far with this technique.
I too faced this issue. To get a detailed explanation on this refer here
Upvotes: 2