Creating Complications for Apple watch - swift

I know how to create the basic watch complications.
I want to create complication like native Battery one (Circular Ring).
How can I fetch live data for the complications, maybe API call, or data from iPhone?
Can I create more then one same complication type?

I want to create complication like native Battery one (Circular Ring).
How can I fetch live data for the complications, maybe API call, or data from iPhone? -
Use WatchKit.framework to do this and use WCSession class to
perform the session talking between the phone and the watch.
You could also use the background tasks API introuduced in WatchOS 3
to make API calls in the background -
https://developer.apple.com/library/content/releasenotes/General/WhatsNewInwatchOS/Articles/watchOS3.html
To update complications in watch OS 3 - https://developer.apple.com/reference/watchkit/wkapplicationrefreshbackgroundtask
Can I create more then one same complication type?
No you cannot, one app can have only one type of complication.

Related

How to design architecture of iOS app with switching datasources

I am designing an architecture for an iOS SwiftUI app and I have no experience with it so I need to clarify few things.
My app will use these datasources:
Bluetooth device
API
CoreData or Realm
Bluetooth device sends data regularly (every 5 minutes) and I have to be able to get them even the app is in the background (or terminated) if possible. Data should be stored somewhere and synced to the API when connected.
Also app should be capable of determining when to use persistent storage and when to use API. One idea is that I would always use for example CoreData and data received from bluetooth device would be stored there (it should automatically rerender view). API will be requested regularly in the background, data from API will be compared with local data and synced appropriately.
I dont’ know, where should I start. I researched commonly used architectures and I really like hexagonal and clean architectures, but I can’t image how to use it correctly.
I didn’t find any resources mentioning switching datasources as the user is online/offline. If is it appropriate to use always CoreData in the app or if I should switch datasources and synchronize with CoreData in the background.

Is it possible to create my own Watch Face on Apple Watch? Not compose from an official one

I tried to google it very hard but it seems blocking, I always end up with tutorials to change the complications and publish it for friends...
What I want to perform is create my own Watch Faces for my Apple Watch, with room for official complications. So I would be able to create my own watch face. Chronology did it, so why wouldn't we? I just don't find the documentation for that.
Please note, I don't want to create a "time-centric" application, I am here talking about real Watch Faces. My goal is to create something where the time only take the place of a small complication, with a custom design of mine, and then I have plenty room for complications from my favorites / personal applications !
This question concerns the Apple Watch (And Watch OS), not WearOS.
Many thanks for your help !
Here is Apple official Documentation about how to add a watch face to your app
Support Shared Complications
To ensure that your app’s complications appear as expected in the watch face preview, you must implement your ClockKit data source’s getLocalizableSampleTemplate(for:withHandler:) method. You can’t just add preview images to the assets catalog.
Then, as soon as the user installs a watch face that includes your app’s complications, the system calls your data source’s handleSharedComplicationDescriptors(_:) method. Use this method to prepare your app so that it can provide complication data for the shared complications.
For example, a weather app may provide separate complications for all of the user’s favorite cities. When the user receives a shared watch face, the app must be ready to provide data for the city associated with the incoming complication, even if it’s not already in the user’s favorites list.
Finally, ClockKit calls your data source’s methods to populate the complication’s timeline. This includes calling getTimelineEndDate(for:withHandler:) and getCurrentTimelineEntry(for:withHandler:), and then calling getTimelineEntries(for:after:limit:withHandler:) if your app supports batch downloading future timeline entries.

What communication to use, updateApplicationContext or sendMessage for constant data sync

I have an iOS shopping list app, where items are added and displayed in a tableView. I want to create a Watch App Extension but I’m thinking of what is the best function call to use in this case, the updateApplicationContext(:) method or the sendMessage(:replyHandler:errorHandler:) method I was reading the documentation but I’m a little confused since both seem to work.
Here is the functionality I’m expecting to have…
What I want is to be able to add items in the iOS app even if the Watch app is Off, which is normal behavior, BUT I want the Watch app to update with whatever is in the tableView (in iOS) as soon as it is turned on and even if the iPhone is not On at the time the Watch is turned on.
In other words, I want the data in the iOS app to always be in sync with the Watch app.
Which is the best function call to use in this case, the updateApplicationContext(_:) method or the sendMessage(_:replyHandler:errorHandler:) method?
Thanks
As for me, I would use updateApplicationContext(_:) since you would want to update it in real time or in the background as it gets connected.
as for this sendMessage(_:replyHandler:errorHandler:) The cons is The isReachable property must currently be true for these methods to succeed. so you might get a slight delay to update your UI until it is reachable and ask for updates.

Core data/Database IOS

I'm new to IOS programming, and I have had a great time learning it. It took me about 4 months to really get a good grasp on it. I have began creating my own app, and I ran in to a few questions. The app I'm creating is a live app like instagram, foursquare, etc. How do I store all of the information I need. Can I use Core-Data to create a real-time app that can handle updates from multiple users?
The app I'm creating is a live app like instagram, foursquare, etc.
How do I store all of the information I need.
You'll probably create some sort of server to manage the data. Having a single, central source of data is a lot easier than trying to sync data between multiple devices.
Can I use Core-Data to create a real-time app that can handle updates from multiple users?
You can -- Core Data works on MacOS X as well as on iOS, so you could write a Mac program that is the server for your iOS app. Whether that's the best approach is another question... I suppose it depends on how well you already know Core Data, whether there are any advantages to using the same Core Data data model on both the server and the client, how many clients you think you might have to support at once, etc.
If you're asking about using Core Data on the iOS client, then yes, you can certainly do that.

iPhone Application Permission

I want to know if it is possible to have two separate applications in iOS Domain where
1) One application is the background application
2) Other acts like Foreground application
The foreground application will use background application for fetching data, data processing and maintaining its database. The user will need to install both applications on his device and for this it should be like this that if user installs one app (say foreground or UI app) it will automatically guide user to install another app. Have heard that something like of this sort is possible in android and applications like voice recognization etc does that.
Also the background application will start running as soon as we boot our device and foreground will launch only after user launches it by clicking on the icon.
Possible advantages in my mind
scenario where one can come with more than one foreground apps. So both of foreground applications can use same background applicatons for maintaining database. This way there will be only one app maintaining database for two different foreground apps on a single device
The background will be the main app will be doing all heavy lifting such as fetching data from server, checking update at regular time intervals and maintaining data base.
Not sure if something of that sort is possible in iOS and is permissible on app store?
Thanks
I've never heard of something like this, especially not on an iOS device.
I don't think it will be accepted for one reason: two different testing teams will test each app. Because the apps require each other, neither app would function. If prompted to install the "other" app, testers would be unable to do so, because it would not be published, because the other team was unable to test it, because the original app was not published. (run on sentence).
It would be like a circle...
My thoughts...
What you are saying could be down with one app and multiple classes and in fact is a fairly common design pattern. You set up one class as the data model, and use background threads and process to keep the data up to date. The other class handles the user interaction on the main thread. Do a few searchs on Model View Controller design pattern and check the link below
https://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html