According to the Apple Watch Programming Guide, developers are only allowed to include 1 glance in their AppleWatch app. This creates a bit of a challenge for me since my app is an aggregate of different types of data so I'm not sure which data set to include in the glance.
That being said, could I get around this by creating multiple AppleWatch apps for my iOS app which would then allow me to create a single glance for each AppleWatch app?
No. Confirmed one Watch app per iOS app.
There is no support for multiple WatchKit apps per iPhone app at this
time.
- Apple's WatchKit Evangelist
You can implement multiple Glance views depending on the user's context (time and location) using WKInterfaceGroups and hiding/unhiding when necessary.
See my answer to the exact same question here https://stackoverflow.com/a/28214768/3588917
Will a timer work for you? For example, when a certain time elapsed, you can change the UI of the glance to show a different type of data? When a user taps a glance, you will be able to tell what data is showing in the glance at the time and pass relevant contextual data and redirect them to an appropriate interface controller?
"When the user taps a glance, Apple Watch launches the corresponding WatchKit app. Normally, launching the app displays its main interface controller. If you want to display a different interface controller at launch time, call the updateUserActivity:userInfo: method from your glance interface controller and use it to provide contextual information about what the glance is doing. At launch time, your app can use that contextual data to display a different interface controller."
Related
I want to add my app in the contact info in the address book for messaging, video calls.
This functionality can be achieve using CallKit, in short CallKit provides native phone app UI to all the VoIP application, to let your app visible in the contact (after integrating the CallKit), you just need to smoothly long press the audio/video call buttons.
By default It shows the most frequent used app (say WhatsApp), once you'll long press the icons it'll show a list of the supporting apps (VoIP enable apps). From where you can choose the app to perform the action.
The screenshots will make you more sense to figure it out.
Image 1 - is the default situation I.e. default call and video option.
Image 2 - Long press the call option, It’ll show all the apps which are capable to make audio call.
Image 3 - Same for the video option.
Image 4 - Once you’ll use any app (suppose WhatsApp) the default icon will change to WhatsApp and in the list it’ll start showing WhatsApp and other concern apps.
Source: #1 Ray Wenderlich Toutorial , #2 Sample Code of CallKit Objective-C & Swift both
Note: - In the list below it’ll start showing the apps name once you use any app to make call. And it’ll remain listed even if you uninstall that particular app.
I assume you are using CallKit. So adding .phoneNumber to supportedHandleTypes gives this ability that you can call number via your application.
.generic also gives ability you can start call from history that made or received via your application.
let config = CXProviderConfiguration(localizedName: "anyname you want")
config.supportedHandleTypes = [.phoneNumber,.generic]
I've a problem, with my app.. I try to follow some guide like Passing data to Apple Watch app , but I'm not sure it will fit for my case.
I've some label with text on my iOS app, then I want to show this text on my watchOS app label, and I don't know which is the best way to pass this text and keep it synchronized with the iOS app..
Thanks a lot for your help!
For watchOS1, Since Watch App is included as an extension in your Host App. So, you can use App Group to share data between your Host App and your App Extension.
Refer to https://stackoverflow.com/a/44654185/5716829 for more on using App Groups.
Since watchOS2, you don't have any built in function for communicating between the iOS and watchOS app than the WatchConnectivity framework.
From the information provided in your question, the updateApplicationContext(_:) function seems to be the best solution for your problem. You can send a dictionary of data with this function and the system tries to make sure that the data is received by the time your app is displayed to the user. If the function is called several times before the app would be visible to the user (run in the foreground), the system overwrites the previous data, so the Watch app only receives the most recent data to display.
The right method for this is WCSession.updateApplicationContext(_ applicationContext: [String : Any]) https://developer.apple.com/documentation/watchconnectivity/wcsession/1615621-updateapplicationcontext "Sends a dictionary of values that a paired and active device can use to synchronize its state."
Is it possible to create pull to refresh action in WKInterfaceTable in watch os 2?
There is one question but its related to watch os 1.
WatchKit pull to refresh
Short Answer:
No, it's not possible.
Long Answer:
All WKInterface Objects are just proxy objects that allows you to send queries to real UI Object. So basically they are not treditional UI Objects.
Connections between real UIs and WKInterface objects are managed by watchOS. What if some WKInterfaceController got deactivated, the connections in it will be disconnected also. In this state, you can't send queries anymore.
You may know that there are two bundles for watch Apps, one takes storyboard and icons, the other one is extension bundle. With sand-box concept, your code(in extension) can't access UI(storyboard bundle sided) directly. The only way to interact is using Interface Builder outlets and sent action.
It(Remote-UI concepts) makes sense for watchOS1 since all the code runs on iPhone. However with some reason, WatchOS2 App also use same strategy. With this restriction, You can't write code that react user interaction to real UI Objects directly likes iOS apps. As I told earlier, You can use pre-defined sent action only.
Since Xcode Interface Builder doesn't provide sent action likes did scroll, You can't write code that react pull down.
I can not use
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
in WatchKit Extension, I have error:
'sharedApplication()' is unavailable: Use view controller based solutions where appropriate instead.
Is there some alternative ?
The short answer is: No there isn't.
The long answer:
Please keep in mind that the extension is not executed on the watch but on your phone. So if you would call UIApplication.sharedApplication() it would return you the application of the extension on your phone, anyway! Everything you do inside your extension is stuff that manipulates the extension on your phone. The only exception from this are the WatchKit methods. And even they are basically calls that are converted into instructions that are send over bluetooth to tell the watch what to do. At no time you can write code that executes on the watch!
You have no control what so ever about what the watch does with the instructions you send to it. You are basically acting as a server talking to a client and you have no control over the client. You should send as little instructions as possible and once you send them, your task is done, the rest is up to the watch.
That being said, you should carefully plan your UI in a way that you do not need any calls that manipulate the event delivery. You should focus on simple 'if user taps x I do y' interaction.
Another thing to keep in mind is, that your extension can not communicate with your main iOS app. You can create a shared app group between your iOS app and your watch extension to share data between them, however you can not directly communicate with your app. If you want to use parts of your apps logic, extract the module in question into a framework (this has become very easy with Xcode 6) and use the framework in both, your app and your extension.
I got one question, Need help. Thanks.
Question: One App have already been created which will delivered Ads based on data, right now, I want to hook this app to another app but without wrapping the whole App to the second App, which i searched would create a static framework, but not that in that, the second App will just deliver one simple ID,and retain one banner space for showing the upcoming Ads, then in my App-server, It will only return the Ads to the second App.
How to do this ?