मैं content-available
एक पुश नोटिफिकेशन पर ध्वज का उपयोग करके एक पृष्ठभूमि प्राप्त कर रहा हूं । मेरे पास है fetch
और remote-notification
UIBackgroundModes
सक्षम है।
यहाँ मैं अपने AppDelegate.m में उपयोग कर रहा हूं:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"Remote Notification Recieved");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"Looks like i got a notification - fetch thingy";
[application presentLocalNotificationNow:notification];
completionHandler(UIBackgroundFetchResultNewData);
}
जब ऐप बैकग्राउंड में चल रहा होता है, तो यह ठीक काम करता है। (अधिसूचना प्राप्त हुई है और ऐप ने "जैसा दिखता है, मुझे एक अधिसूचना मिली" स्थानीय अधिसूचना को ट्रिगर किया, जैसा कि ऊपर दिए गए कोड को करना चाहिए)।
हालाँकि, जब ऐप नहीं चल रहा होता है और content-available
ध्वज के साथ एक पुश सूचना प्राप्त होती है , तो ऐप लॉन्च नहीं किया जाता है और didRecieveRemoteNotification
प्रतिनिधि पद्धति को कभी नहीं बुलाया जाता है।
मल्टीटास्किंग के साथ WWDC वीडियो Whats New (WWDC 2013 से # 204) यह दिखाता है:
यह कहता है कि आवेदन "पृष्ठभूमि में लॉन्च" किया जाता है जब content-available
ध्वज के साथ एक धक्का अधिसूचना प्राप्त होती है ।
मेरा ऐप पृष्ठभूमि में लॉन्च क्यों नहीं हो रहा है?
तो असली सवाल यह है:
उपयोगकर्ता द्वारा ऐप छोड़ने के बाद क्या iOS पृष्ठभूमि कार्य करेगा?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions