WatchConnectivity on Xcode 14 - watchos

I made a "todo" app, using core data, and want to extend it to apple watch. The main problem is that when I run the simulator, the watch seems to be not connected with iPhone.
I tried to import WatchConnectivity, use WCSession, delegate, and they are all not working because the watch is not getting connected with the phone in the first place.
I am using SwiftUI, but not storyboard

Related

How to set PresentingViewController with current ViewController in iOS 7+

In my iOS 7+ app I'm using the latest version of Harpy, which perform an app version check and present an alert if there's a new version of my app available in the App Store.
Due to the structure of my app, I'm facing this issue in the debugger:
Attempt to present <UIAlertController: 0x144538530> on <DCLoginViewController: 0x14460c1a0> whose view is not in the window hierarchy!
this is because harpy is configured in the AppDelegate and has a parameter that define the presentingViewController:
[[Harpy sharedInstance] setPresentingViewController:_window.rootViewController];
I believe the issues arise because my app check if the user is already logged in, if so, instead of presenting the DCLoginViewController, it jumps to the next view which is "LoadingViewController".
How can I set the presentingViewController to be this LoadingViewController or even the ViewController currently on screen at execution time?
Thanks for your help.
You don't have to launch Harpy in the AppDelegate. You can launch it after LoadingViewController has loaded. It's only recommended to launch it in the AppDelegate as the idea is to show the alert as soon as the app is loaded. It's more of a UX thing than anything else.

How to simulate the Local Notification in apple Watch App?

I am trying to simulate the local notification view in apple watch simulator. Does any one known how to simulate the local notifications in apple watch ?
I have done some research for that but didn't found any answer for the above. There is a way to simulate the PUSH NOTIFICATION but not for the LOCAL NOTIFICATION.
It is not possible to have a Watch app react to a UILocalNotification in the simulator. However, it is almost identical to reacting to a push notification, except it gets routed through a couple of different methods.
If you're presenting an actionable notification, your WKUserNotificationInterfaceController subclass would override -didReceiveLocalNotification:withCompletion: instead of -didReceiveRemoteNotification:withCompletion:.
If your Watch app is getting launched in response to interacting with one of your actionable notifications, then your root WKInterfaceController would implement -handleActionWithIdentifier:forLocalNotification: or -handleActionWithIdentifier:forRemoteNotification:, as appropriate.
From WatchKit's point-of-view, those are the only distinctions between remote and local notifications.
Run your watch app (notification target) on simulator, dismiss the notification and stay on clock face.
Switch to iOS simulator and create a notification. For testing purposes setup fireDate to something reasonable like:
notification.fireDate = NSDate().dateByAddingTimeInterval(10)
Here goes the trick. Hit ⌘L to lock iOS simulator.
Enjoy notification arriving to watch app.

In OS X 10.9 (xcode 5.1), how to show local notification on top-right(menu bar) in my program?

Why local notification is no supported by OS X 10.9? I know IOS has UILocalNotification Class.
I want to show some notification bellow menu bar which is generated by my program.
Is there any alternate way to do this? Or should I write my own local notification view?
It sounds like you are looking for NSUserNotification functionality, which goes along with the MacOS NSUserNotificationCenter.
I've linked the documentation at Apple to help you out.
As you are learning, many classes and objects supplied in the iOS SDK don't have exact same classes and objects in the MacOS SDK. Anything with "UI" in the framework name is usually meant only for iOS.

cocoa bindings - [NSArrayController removeObjects] doesn't really delete objects from database, but it doesn't show it again

I'm working on a data-driven iOS app.
I've finished a helper mac os app with core data&cocoa Bindings to prepare data to preload on the iOS app.
Suddenly on using the pre-loaded .sqldata file, I found empty objects.
I was using NSArrayController's add/removeObjects methods in the helper app.
I think the problem is that removeObjects doesn't really delete the objects from the database table.
Any help please to make sure it is deleted successfully from database, not only from the array controller?
I'm working on a data-driven iOS app ... using NSArrayController's add/removeObjects methods.
NSArrayController does not exist on iOS, so you're going to have problems trying to use it. I'm guessing that you're working on the simulator at this point. That's convenient, but the simulator lets you get away with stuff that's not valid on a real device. If you're working on an iOS app, fixing problems with NSArrayController is a waste of time, and the best move would be to get rid of it as soon as possible.
Ok, I solved the problem. The problem was that I deleted the object from the NSArrayController, but forgot to delete it first from the ManagedObjectContext.

App won't relaunch when monitoring CLLocationManager significant location changes - iPhone

I am working on an app that keeps track of user's location at a time-interval set by the user himself(e.g. every 5 minutes) and sends it to a server page by ASIHTTPRequest.
This app should be able to receive updates on foreground, either on background or even when the app is not running(location services).
Although my app successfully receives updates on the foreground and background, it does not seem to wake up when it is not running and do not send me up any requests to the server.
I am using CLLocationManager and its delegate to perform startMonitoringSignificantLocationChanges for when it is on the background.
On Settings, the icon for my app in Location Services appears with a purple arrow as expected.
On my info.plist, I have Required Background Modes set with an item locations as required and methods:
locationManager:didUpdateToLocation:fromLocation:
locationManager:didFailWithError:
implemented.
My method:
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
is also implemented and checks whether launchOptions
contains UIApplicationLaunchOptions- LocationKey before starting the significant locations monitoring for when it should wake up / relaunch.
Is there any way I can find out whether my app is really being relaunched?
Is there any extra config that needs to be set in order this to work?
Please let me know if I should provide any additional info.
Specs I am using:
SDK Xcode 4.2.1
CLLocation is inside a Singleton class (read somewhere this might impact)
iOS deployment target: 4.3
Tested on Iphone 3GS,4 and Xcode's iOS 5 simulator, same behavior happens to all of these devices.
Devices:universal
UPDATE
I inserted my code inside -[UIApplication beginBackgroundTaskWithExpirationHandler:] and tried to check against errors with UIBackgroundTaskInvalid. However, it does not even seem to enter the (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method.
I am keeping track of the app by trying to save and retrieve data by using SQLite. When executing on both foreground and background, it records the data with no problem. When the app is not running, no data is saved at all.
How are you currently checking to see if the app relaunches? Are you logging anything?
The app will relaunch to the background, so you won't see your app come alive. It will actually shut down automatically after some time again. You can do some work and request more background time using -[UIApplication beginBackgroundTaskWithExpirationHandler:].
Another answer here on SO posted some example code. From your description I cannot see anything missing, compare your code to that project to see if your missing something.