Search code examples
iosruby-on-railsruby-on-rails-3ios5faye

How do I know If IOS App in background using faye server


I have been implementing Faye for our IOS chat application. Since I don’t know much about the IOS side, I am little bit confused. Every thing works fine but my client asks me to check if IOS app has received the push message but as far as Faye is concerned it only checks /meta/disconnect and /meta/unsubscribe channel for client deactivation but how do i know that IOS app goes to background because than I have to send msg through APNS. But my client doesn’t want to hit Rails API to tell browser about the APP Status. Little bit confused please help me.


Solution

  • You can know your app goes in background when this method from your ApplicationDelegate is called :

    - (void)applicationDidEnterBackground:(UIApplication *)application
    

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UIApplicationDelegate_Protocol/Reference/Reference.html

    You can also listen for the UIApplicationDidEnterBackgroundNotification event from any controller :

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(appHasGoneInBackground:)
                                                 name:UIApplicationDidEnterBackgroundNotification
                                               object:nil];
    

    Here is a thread that covers this subject :

    Use of background/foreground methods in AppDelegate