Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMPP app terminate and not recive message

I am working in XMPP Application. When I terminate and kill My Application than,

1)User is Not Connected In XMPP Server. User is Offline. But I want User is Connected and Online. Like Whats App(Appliction).

2)I can't get Any Messages From XMPP Server Side at that time,

- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message

This method is not call. So, How Can I get Messages ?

And i also implement Pushnotification but in this way same issue Like,When app is Kill and Terminate than,This method is not call,

- (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler 

So, Please Guide me In Proper Way and Suggest me How to work as like same Whats App(Application).

Also, We can't set VOIP Flag In .plist file Because this way is not Proper and reject by the apple.

My Goal is Only Notification Work As like Whats App.

like image 573
Raju Avatar asked Apr 14 '16 14:04

Raju


2 Answers

1)User is Not Connected In XMPP Server. User is Offline. But I want User is Connected and Online. Like Whats App(Appliction).

Once you closed or minimized WhatsApp the user gets offline (tested on iPhone4s), and messages received in this state are as push notifications.

2)I can't get Any Messages From XMPP Server Side at that time,

  • (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message

This method get called only when application is active. So you can not get messages here after you killed your application.

- (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler 

This method will get called in following scenarios

  1. If your app is active and you got any new push notification.
  2. If your app is in background or killed or not started then system will show only notification on the top bar, once user tapped on notification it will open your application and then the method will get called.

And of course you can not use VOIP.

WhatsApp shows custom notification when user is active in WhatsApp. You need to send push notification for every message of your conversation. In this case

  1. If user is active then show your custom notification in app.
  2. If user is inactive (i.e. killed or minimized app) then system will show Notification in notification center.

When user taps on notification, system will launch application, and you have to check for app launching conditions (from which source app launched) and according to conditions join server/chat (or groups if you are using group chat).

Once you joined server with your name/nickname, you will get recent chats. You can also get history, you need to specify while joining chat server / group.

Make sure you are disconnecting from server and also from group when your app is getting minimized or killed. Use following methods to disconnect and/or related changes

 1. - (void)applicationDidEnterBackground:(UIApplication *)application
 2. - (void)applicationWillTerminate:(UIApplication *)application

Hope this will help you, I have implemented same to achieve expected results as WhatsApp.

like image 105
Haripal Wagh Avatar answered Sep 20 '22 20:09

Haripal Wagh


When your app kill, that time XMPP Deactivate all service.So, you can send webservice to server which can tell - you are offline.

Then after sever can send you Push notification all chat content.

like image 34
Mahipalsinh Avatar answered Sep 20 '22 20:09

Mahipalsinh