Xiaomi does not receive notification when application is not running

前端 未结 4 1723
遇见更好的自我
遇见更好的自我 2020-11-29 04:24

I am working on an application where I am using Google Push Notification. Application receives notification when it is running in Xiaomi phone otherwise when it\'s killed it

4条回答
  •  感动是毒
    2020-11-29 04:54

    I faced a similar issue and fixed it by adding a BOOT_COMPLETED receiver to my app.

    Add following to manifest :

    
        
           
        
    
    

    Then create your BootReceiver class

    public class BootReceiver extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
    
                Intent startServiceIntent = new Intent(context, FBTokenService.class);
                context.startService(startServiceIntent);
    
                Intent notificationServiceIntent = new Intent(context, FBNotificationService.class);
                context.startService(notificationServiceIntent);
            }
        }
    }
    

    It should work with this.

提交回复
热议问题