10
votes

We are facing the problem in sending GCM push notifications to all the android devices. We are developing an app on Ionic platform and using the plugin called cordova push for the push notifications. The device is registering with gcm and receiving device token. I am using 3 devices to test Moto g4 plus, MI4 and Letv.

The problem is push notification is reaching to moto g4 plus device but not to MI and Letv devices when the app is killed. MI and Letv devices are also receiving the notification only when the app is in the foreground or background.

I am receiving delivery receipts from gcm as delivered to all the devices in the app killed case too.

Please suggest some solution to overcome this problem. Thank you.

1

1 Answers

4
votes

I also faced this issue I have Xiaomi mobile that needs 'Autostart Permission' to receive FCM Notification when app is killed,you need to move your app in this list.

For Xiaomi device you can ask user for this permission Check the answer here

    String xiaomi = "Xiaomi";
    final String CALC_PACKAGE_NAME = "com.miui.securitycenter";
    final String CALC_PACKAGE_ACITIVITY = "com.miui.permcenter.autostart.AutoStartManagementActivity";
    if (deviceManufacturer.equalsIgnoreCase(xiaomi)) {
        DisplayUtils.showDialog(activity, "Ask for permission", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                try {
                    Intent intent = new Intent();
                    intent.setComponent(new ComponentName(CALC_PACKAGE_NAME, CALC_PACKAGE_ACITIVITY));
                    activity.startActivity(intent);
                } catch (ActivityNotFoundException e) {
                    Logger.e(TAG, "Failed to launch AutoStart Screen ", e);
                } catch (Exception e) {
                    Logger.e(TAG, "Failed to launch AutoStart Screen ", e);
                }
            }
        }, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
    }

And as for Letv mobile i haven't checked it.If you have solved it then do tell me.