I am creating a chat app using smack using openfire sever by XMPP protocol. I can chat with other user and working well. I created connection in Service class. So i am able to get notification message when i am not in my application but i get my service is restarting again and again when network problem, network change, network slow etc. So my connection is lost. and user is not always able to chat.
So i solved connection problem. like as
if( service is not runing)
start my service
else
if(connection is NULL or not Connected)
reconnection . so my connection is created
My service class:-
if(connection is NULL or not connected)
reconnect. so my connection is created
else
not connected.
But now if my service is runing and connection is lost. and i open my application , a new connection is created. This connection is created by application not services. So now when i am not in my app , i did not get any notification for incoming message because incoming message was coming by service connection.
Now i have involved. please expert help me. How can i solve?
Is there way for push notification in openfire?