What's the equivalent of app delegate file for apple watch app? - appdelegate

I want to set the initial view controller for the watch app base on different type of notification received on the watch. But I don't know where's to set it.
This is the answer for an iOS app
Multiple entry points to a storyboard

watchOS 2
WKExtensionDelegate is the equivalent of the app delegate, where you can:
respond to actionable notifications and manage Handoff transitions. You also use the delegate to respond to life-cycle events, such as the activation and deactivation of your app
In applicationDidFinishLaunching(), you can call reloadRootControllersWithNames(_:contexts:) to specify the set of pages displayed when your app launches.
You can also call reloadRootControllersWithNames(_:contexts:) at runtime to switch view controllers.
watchOS 1
There's no app delegate equivalent.
To create a custom per-notification UI, create a new Notification Interface Controller with a distinct name for the Notification Category. If you need additional customization, see Managing a Custom Long Look Interface in the docs. Specifically:
When a notification of the correct type arrives, WatchKit chooses your static or dynamic interface based on several factors. WatchKit automatically displays the static interface when a dynamic interface is not available, there is not enough power to warrant displaying the dynamic interface, or you explicitly tell WatchKit not to display the dynamic interface. In all other cases, WatchKit displays your dynamic interface. After making the choice, WatchKit loads the appropriate storyboard resources and prepares the interface as shown in Figure 16-2. The loading process for the dynamic interface is mostly the same as for your app’s other interface controllers, with the exception of processing the notification payload, which is specific to notification interface controllers.
The category name should exactly match the category field in your push notification JSON, like INVITE_CATEGORY in this example:
{
"aps" : {
"alert" : "You’re invited!",
"category" : "INVITE_CATEGORY",
}
}
(If you're using local notifications, not push notifications, just set the category property on your UILocalNotification.)
Apple Watch will display the notification interface controller corresponding to your category.
See also Notification Essentials.

In WatchKit 2 there is an extension delegate.
From watchOS 2 Transition Guide
In watchOS 2, your WatchKit extension has an extension object and corresponding delegate object to manage behavior that is central to your app. The WKExtension object is a shared object that is available whenever your Watch app runs. The extension object has an associated delegate object that conforms to the WKExtensionDelegate protocol.

Related

watchOS app resets to root view controller after display sleep

I'm implementing a simple hierarchical interface for a watchOS app, using pushController(withName: String, context: Any?) to add views onto the stack. When trying to test on a watchOS 3 device, my app will reset itself back to the root view controller, losing the navigation state, after a "sleep" event.
Is this expected behavior? I would expect the navigation state to reset if the app was purged from memory, but not after the screen goes to sleep.
Setting the app target to watchOS 3 and implementing the handle(_:) WKExtensionDelegate method (which I had not done, since the watchOS targets were generated under Xcode 7) seems to provide the behavior I expected.

PushApps for iOS - how to handle the push dictionary in my root view controller?

I want to handle the push notification dictionary in my root view controller (and not in my AppDelegate), but when using a NSNotification it does not work! Why?
Working with NSNotification to pass the push notification dictionary, will work only when the app is already open. The reason for that is that the root view controller is not yet initialized, when the push notification is handled (at startup).
Implement PushApps delegate and specific that method
Inside this method, save the push notification dictionary to the NSUserDefaults.
Inside your root view controller ViewWillAppear method, take the parameters back from the NSUserDeafults
Do not forget to erase the dictionary from the NSUserDefaults, so that next time you won’t handle the same push notification again.

Why does the Xively developer portal show a device is private when in fact it is public?

I have created a number of devices in my Xively account and always selected "private access" in the create wizard. I recently noticed that some of these devices are publicly accessible, even though the Xively portal is telling me they are private. If I use the portal to change the access to public and back to private again then they are no longer publicly accessible. Does anyone know why some devices are public when the portal says they are private?
I've found the reason for this now. There are actually two problems which combine to cause what I think is quite a nasty data privacy issue.
Firstly, the Xively portal does not accurately reflect the current accessibility status (public or private) of a feed; it shows the status that was selected when the device was created or subsequently modified via the portal, however if an application changes the status via the API this change is never reflected in the portal UI. If your application accidentally changes the status from private to public the portal will continue to display "private" whenever you look at it.
Secondly, there is a bug in the Xively Java library which changes a device's status to public whenever you use the library to update a device (e.g. submit a reading). The update() method of the FeedRequester class submits every attribute for a feed whether you specify the attribute or not. In most cases this doesn't matter because the method sends a value of null for unspecified attributes which the server (presumably) ignores. The one exception is the "private" attribute - in this case if your application does not specify a value the library will send a value of false, not null, presumably because the attribute is stored in the Java library as a Java primitive type (boolean) and not an object. The net effect is if you call this method without explicitly setting private to true, your device's status will be changed from private to public without you realising it.

What is the best way to implement a inter-qwebview communication?

Overview:
I am trying to create a PoC application that mimics WebIntents-like feature.
So, in my Qt application, I create two QWebviews launching two different webApps. Now let's call them apps A and B.
Scenario:
Main Application creates two QWebViews each launching an App i.e. AppA, AppB.
App A is programmed to fetch some data via AJAX, automatically.
App B also needs part of that data. AppB simply displays a button (HTML) called .
Note: Since, AppA already has that info, I would like the AppB to invoke a JavaScript API which was injected into it's(appB) DOM by means of addToJavaScriptWindowObject() method call when the QWebView was launched.
App-A completed the Ajax Call and indicates the completion in its WebView.
User clicks the button in AppB,
App B invokes that JavaScript API i.e. fetcData({source: "AppA");
Now the control is in the QT-world:
Question: the Control is in the context of AppB, How should I communicate with the WebView in AppA -- i.e. AppB asks AppA: hey AppA, please give me that data that you have fetched?
Can Signals and Slots help me here? Or should I use some other form of IPC.
I read this page: http://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html, but I still didn't get a hint for a solution for my problem.
Another related question: Are QWebViews created in their own threads ?
Can't you just emit some sort of signal from AppB that basically says, "Hey, I finished fetching my data if anyone wants it" or am I missing something? It would happen at the end of AppB::fetchData().
All you have to do after that is connect any interested objects to that signal.

How to access log information for ColdFusion server in Flex

I have Flex front end talking with ColdFusion as the back end. I have to debug my application and need to:
Add log support to ColdFusion where I can add my custom messages to log list
Access this log at Flex end.
Is it possible? Has anyone tried it before? Please help me with your suggestions ideas on this.
My recommendation :
Flex-side :
Create custom LogEvent objects that carry an id, a message, any other properties you want to log.
Dispatch those events whenever you want to Log an action or system event that occurs
Create a LogManager that's in charge of catching these events, and using a Delegate to make a ServiceCall to your ColdFusion services
ColdFusion :
Create a Logging service with APIs for listening for any service-calls from the Flex application
Save these log events into your database
Create a service that the Flex app can call to retrieve LogObjects (or whatever DAO you want)
Flex :
Create a LogView (a datagrid / advanced data grid with a column for every log property you want (essentially a mirror of the database log entries)
Create a delegate that your LogManager can use to call that Coldfusion Log Service to retrieve these Log Objects
I'm not sure if you're using a framework (Cairngorms, SWIZ, etc.) so my description of these objects is a little more abstract that you could do it all custom, or put it into your existing framework.
I've done this before, for AnalyticsEvents for GoogleAnalytics (worked with ExternalInterface) and with LogEvents for USER actions and SYSTEM actions.

Resources