uiapplicationdelegate

how to determine in applicationDidBecomeActive whether it is the initial iPhone app launch?

China☆狼群 提交于 2019-12-03 07:26:33
how to determine in how to determine in UIApplicationDidBecomeActiveNotification whether it is the initial app launch?whether it is the initial app launch? that is the initial start up of the application, as opposed to subsequent DidBecomeActive's due to the application being put in background and then to foreground (e.g. user goes to calendar then back to your app) In your applicationDidFinishLaunching:withOptions: put this: [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"alreadyLaunched"]; [[NSUserDefaults standardUserDefaults] synchronize]; Then, in didBecomeActive : if ([

Detect if application: didReceiveRemoteNotification: fetchCompletionHandler: was called by tapping on a notification in Notification Center

倾然丶 夕夏残阳落幕 提交于 2019-12-03 02:14:46
问题 application: didReceiveRemoteNotification: fetchCompletionHandler: is different from application: didReceiveRemoteNotification: How? from the docs: Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running, the system calls this method regardless of the state of your app. If your app is suspended or not running, the system wakes up or launches your app and puts it into the background running state before calling the method. If the user opens

How do I access my Application Delegate's window accessor method from another object?

折月煮酒 提交于 2019-12-02 22:20:19
As mentioned before - I'm an Objective-C newbie of the first order but having read 4 physical books on the subject and a bucket-load of ebooks and documentation I still can't find what I'm looking for. I have a top-level content view controller that wants to configure its view property from the physical dimensions of the window property of the application delegate. This is something that several people have already asked questions on. ( [UIScreen mainScreen] doesn't cut it for reasons already aired many times before on this forum). Therefore, the logical approach would be for the content view

Detect if application: didReceiveRemoteNotification: fetchCompletionHandler: was called by tapping on a notification in Notification Center

寵の児 提交于 2019-12-02 17:16:36
application: didReceiveRemoteNotification: fetchCompletionHandler: is different from application: didReceiveRemoteNotification: How? from the docs: Unlike the application:didReceiveRemoteNotification: method, which is called only when your app is running, the system calls this method regardless of the state of your app. If your app is suspended or not running, the system wakes up or launches your app and puts it into the background running state before calling the method. If the user opens your app from the system-displayed alert, the system calls this method again so that you know which

Delete data when app is killed in the background.

陌路散爱 提交于 2019-12-02 15:36:00
问题 I have an app where I am saving data but when the app is killed in the background I have to delete all the saved data. I tried using this method: - (void)applicationWillTerminate:(UIApplication *)application But its not working. Can someone please suggest me how to do that? 回答1: Not sure why you need to wipe the data on terminate specifically, but here is something to consider: Another way to handle this type of situation when apps write data that may be incomplete when they are forced to

What is the equivalent of UIApplication.sharedApplication().delegate in WatchKit?

你。 提交于 2019-12-02 04:02:07
问题 In an iOS application, you can obtain a reference to the shared app delegate by: Swift: let delegate = UIApplication.sharedApplication().delegate as! AppDelegate Objective-C: AppDelegate *delegate = [[UIApplication sharedApplication] delegate]; In a WatchKit2 App Extension there is a similar App Delegate and I want to obtain a reference to it in a view controller to access shared resources in the app, such as the ManagedObjectModel and PersistentStoreCoordinator for the Core Data stack, that

How to call a function in applicationDidEnterBackground?

馋奶兔 提交于 2019-12-01 11:25:15
I want to call a function in applicationDidEnterBackground this function is defined in other controller. I have made an object to access it but it seems that function is getting killed when called. Here is the function it basically calculates the distance and postes a notification -(void)calculateDistance { for (NSMutableDictionary *obj in placeName) { CLLocation *userLocation = [[AppHelper appDelegate] mLatestLocation]; CLLocation *annotation1 = [[CLLocation alloc] initWithLatitude:[[obj objectForKey:@"Lat"]doubleValue] longitude:[[obj objectForKey:@"long"]doubleValue]]; CGFloat distanceTemp

How to call a function in applicationDidEnterBackground?

无人久伴 提交于 2019-12-01 08:00:24
问题 I want to call a function in applicationDidEnterBackground this function is defined in other controller. I have made an object to access it but it seems that function is getting killed when called. Here is the function it basically calculates the distance and postes a notification -(void)calculateDistance { for (NSMutableDictionary *obj in placeName) { CLLocation *userLocation = [[AppHelper appDelegate] mLatestLocation]; CLLocation *annotation1 = [[CLLocation alloc] initWithLatitude:[[obj

UIApplicationBackgroundRefreshStatusDidChangeNotification usage without corresponding delegate method

非 Y 不嫁゛ 提交于 2019-11-30 10:11:48
I feel that UIApplicationBackgroundRefreshStatusDidChangeNotification introduced in iOS 7 is of little use without supporting UIApplication delegate method. Because, the app is not notified when user has switch ON the background refresh state for my app. This is my notification handler... - (void)applicationDidChangeBackgroundRefreshStatus:(NSNotification *)notification { NSLog(@"applicationDidChangeBackgroundRefreshStatus with notification info = %@ and refresh status = %d", notification, UIApplication.sharedApplication.backgroundRefreshStatus); if (UIApplication.sharedApplication

Counterpart to -application:openURL:sourceApplication:annotation:

和自甴很熟 提交于 2019-11-30 08:11:50
iOS SDK 4.2 includes a new UIApplicationDelegate method called application:openURL:sourceApplication:annotation: . It is a replacement for application:handleOpenURL: and offers more information about the calling application: not only do we get the bundle identifier of the calling app, but also, in the annotation argument, A property-list object supplied by the source application to communicate information to the receiving application. Great, this should offer a lot of opportunities for a more direct interaction between multiple third-party apps! The only problem is: how do I invoke this