0

We are trying to develop a Messaging Application(Mobile) like Viber. We are now woking on User Status (The user is online or not). We have tested Viber yesterday and understand that if a user close the application or if a user goes out of the Network, rest of other users got it immediately. I mean rest of the users got that the User was Online 'a moment ago'

I know that if the user change his Status, or if a user close the application, an event can fire a request to the server and inform that the user is not online now. And the Server then notify everyone(related users) that message by using Push Method. But if the user goes Out of Network(Disable wifi/cellular), how everyone (related users) get Notified?

What is the efficient way? Any reference link?

Thanks..

sumon
  • 742
  • 1
  • 11
  • 33

2 Answers2

0

change the colour of your online/ offline button in these methods appdelegate.m

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

this will work for ios

Cœur
  • 37,241
  • 25
  • 195
  • 267
Noor
  • 2,071
  • 19
  • 28
  • thanks, but may be you didn't understand my question. I can change where it is necessary, but how everyone actually notified about a Status change if the users app doesn't notify to the Server. – sumon Mar 04 '14 at 07:45
  • you will need to send status to server from these methods – Noor Mar 04 '14 at 09:37
  • can you understand now? – Noor Mar 04 '14 at 09:40
0

You're right about how these protocols work. If a user shuts off, it immediately broadcasts to peers that they're no longer on the network.

But like you mentioned, this doesn't work when someone crashes or loses signal. Generally you want to keep polling the user to make sure that they're still there. There's an efficiency cost, and the amount of time you wait between each poll is something you should determine. There's a tradeoff between immediately being informed vs. polling too frequently and sucking up resources.

Update:
I might be wrong, but I think that viber/what is probably polling, and since it's polling frequently it looks like it's immediate.
I don't know how it would otherwise be possible to inform the programs if it crashes, since crashing means it can't functionally send any kind of signal. So it must be polling so frequently that it seems immediate.

antimatter
  • 3,240
  • 2
  • 23
  • 34
  • But if someone crashes or looses signal, viber/what app updates it immediately. I want to know how that apps work actually. I can implement it in any way, but my concern is what is the efficient way. thakns for your reply :-) – sumon Mar 04 '14 at 07:43