3

I am implementing Mqtt to get push notification from server, getting connected successfully and getting notifications when app is open, and app is in background. but not getting push notification when app kill or close. How should i implement my service and register Callback, don't no if AlaramManager and broadcast receiver are needed . Help me!

Pratibha sarve
  • 369
  • 2
  • 11

1 Answers1

0

You need 2 parts

  1. First you need to make sure that you use persistent sessions, e.g. make sure you always use the same client id for a given client and you set the cleanSession flag to false so the broker will queue messages while the client is disconnected.

  2. You need to make sure the service is restarted when it's killed, this SO question should help

Community
  • 1
  • 1
hardillb
  • 54,545
  • 11
  • 67
  • 105
  • MqttCallBack is implemented for my service, i am starting service with flag START_STICKY, but not getting new message from Mqtt when app kills. is this like on killing of app listener also killing?, how broadcast receiver work here? – Pratibha sarve Sep 02 '16 at 05:22