मैं कैसे पता लगा सकता हूं कि एक ऐप अभी "पृष्ठभूमि मोड" से वापस आया है? मेरा मतलब है, मैं नहीं चाहता कि मेरा ऐप डेटा (प्रत्येक 60 सेकंड) प्राप्त करे जब उपयोगकर्ता "होम बटन" दबाए। लेकिन, मैं पहली बार ऐप अग्रभूमि मोड में कुछ "विशेष" अपडेट करना चाहता हूं।आईफोन 4 एसडीके: पृष्ठभूमि मोड से वापसी का पता लगाएं
मैं इन दो घटनाओं कैसे पता लगा सकते हैं:
- एप्लिकेशन पहले से अग्रभूमि मोड के लिए जा रहा
धन्यवाद
// Register for notification when the app shuts down
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myFunc) name:UIApplicationWillTerminateNotification object:nil];
// On iOS 4.0+ only, listen for background notification
if(&UIApplicationDidEnterBackgroundNotification != nil)
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myFunc) name:UIApplicationDidEnterBackgroundNotification object:nil];
}
// On iOS 4.0+ only, listen for foreground notification
if(&UIApplicationWillEnterForegroundNotification != nil)
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myFunc) name:UIApplicationWillEnterForegroundNotification object:nil];
}
नोट::
फ़्राँस्वा
धन्यवाद देखो! –