uiapplicationdelegate

Detecting when app is becoming active from lockscreen vs other on iOS7

☆樱花仙子☆ 提交于 2019-11-28 09:58:06
My app has different behavior when becoming active from the lockscreen (locked while active), or becoming active from anything else. On iOS 6 and lower I could detect this UIApplicationState state = [[UIApplication sharedApplication] applicationState]; if (UIApplicationStateInactive == state) // Coming from locked screen (iOS 6) else // Coming from Springboard, another app, etc... But on iOS 7, the state value is UIApplicationStateBackground in both scenarios. Is this the intended behavior? How can I properly detect whether the app is launching from the lockscreen now? Registered devs, I

Why not enforce strict singleton application delegate object to use in NIBs?

旧街凉风 提交于 2019-11-28 09:55:12
问题 I just ran myself round in circles, all coming down to having instantiated an app delegate object in a secondary NIB that wasn't the NSMainNibFile . Amazing how having two app delegates kicking around means you have separate managedObjectContexts . Here's a thought-- could I make my application delegate class a singleton? And safely instantiate it in more XIBs? What would that break? Also, there are some mentions on stackoverflow that [[UIApplication sharedApplication] delegate] is a

Background request not execute Alamofire Swift

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 09:23:52
I'm trying to make calls in background like POST,GET to be more precise in the didReceiveRemoteNotification method, because they start to work as a push notification arrive. My problem is that all the Alamofire.request are never call in Background mode until I open the app. I have by now Im was trying to open a session but it won't make the request work. These is what i want to execute in background (cellphone in background) Alamofire.Manager(configuration: configuration).request(.GET, url, parameters: nil) .responseJSON { (_, _, JSON, _) in //println(JSON) println(JSON) REST OF THE CODE But

applicationDidEnterBackground and applicationWillEnterForeground method are not called when pressed home button in iOS simulator

这一生的挚爱 提交于 2019-11-28 05:32:15
问题 I need a long running task to be done in background as well as in foreground. This updates the core data. So to maintain UI responsive I created an another thread where I use different managedObjectContext(MOC). So a timer is set in background as well as in foreground and is inactivated appropriately when state changes. Before the task is starting and after the task is completed when I press home button it calls the two delegate methods properly but during the task is active when I press home

iOS Application Background Downloading

空扰寡人 提交于 2019-11-28 05:08:41
Hey! I need to know how I can have my iOS Application start a download in the background of the application (like, have the download run in the AppDelegate file) so changing ViewControllers will not interrupt or cancel the download. I also need to be able to get the progress of the download ( 0.00000 - 1.00000 ), to set a UIProgressView object to, which also means I need a - (void)progressDidChangeTo:(int)progress function. Piotr Czapla Just use ASIHTTPRequest it is way easier than NSURLRequest and does exactly what you need. It examples that shows how to download in background and how to

UIApplication sharedApplication - keyWindow is nil?

送分小仙女□ 提交于 2019-11-27 23:26:13
I want to convert a CGPoint from my UIView to UIWindow coordinates and have realized that UIApplication keyWindow is always nil; why is this? I have tried the convertPoint:toView: method from UIView. Please see this sample code I tried in the view controller in a template of Xcode (View application): - (void)viewDidLoad { [super viewDidLoad]; UIView *test = [[UIView alloc] initWithFrame:CGRectMake(40,40,250,250)]; [test setBackgroundColor:[UIColor redColor]]; [self.view addSubview:test]; CGPoint p = CGPointMake(100, 100); CGPoint np; np = [test convertPoint:p toView:[[UIApplication

Is there any way to check if iOS app is in background?

随声附和 提交于 2019-11-27 17:28:25
I want to check if the app is running in the background. In: locationManagerDidUpdateLocation { if(app is runing in background){ do this } } DavidN App delegate gets callbacks indicating state transitions. You can track it based on that. Also the applicationState property in UIApplication returns the current state. [[UIApplication sharedApplication] applicationState] Aswathy Bose UIApplicationState state = [[UIApplication sharedApplication] applicationState]; if (state == UIApplicationStateBackground || state == UIApplicationStateInactive) { //Do checking here. } This may help you in solving

didReceiveRemoteNotification: fetchCompletionHandler: open from icon vs push notification

只谈情不闲聊 提交于 2019-11-27 05:59:41
I'm trying to implement background push notification handling, but I'm having issues with determining whether the user opened the app from the push notification that was sent as opposed to opening it from the icon. - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { //************************************************************ // I only want this called if the user opened from swiping the push notification. // Otherwise I just want to update the local model //******

Local notification on application termination

会有一股神秘感。 提交于 2019-11-27 05:05:45
I am working on an application which will not work if terminated. It has some background tasks. I want to show a local notification if the app is terminated. There are applications which do this which means this is doable. But I am not able to find out a way. I have tried to set up a local notification in applicationWillTerminate: method of appdelegate as well as added a notification of app termination in my viewcontroller but none of the methods get called when app is actually terminated. - (void)applicationWillTerminate:(UIApplication *)application { NSLog(@"terminated"); UIApplication * app

What describes the Application Delegate best? How does it fit into the whole concept?

江枫思渺然 提交于 2019-11-27 03:40:24
I think to know what the App Delegate does. It has some nice methods like -applicationDidFinishLaunching which will be called when the app has finished launching, and so on. But what's that actually? Is that some object instantiated in the UIApplicationMain function? And how does it work that every class in my app has access to that App Delegate object? Is there any good graph on the net that visualizes these relationships? In Cocoa, a delegate is an object that another object defers to on questions of behavior and informs about changes in its state. For instance, a UITableViewDelegate is