This pull request adds support for a Apple Watch Extension to be able to openParentApplication and have a Titanium application reply.
This pull request is related to the Jira ticket TIMOB-18854.
This pull request consists of a few different parts.
1.Application Delegate
This pull request adds a delegate method to Tiapp.m this delegate raises the Ti.App.iOS watchkitextensionrequest event. The userInfo provided by the extension openParentApplication is passed through to the watchkitextensionrequest event. The reply method of the delegate is captured and placed into an NSDictionary. This allows for the reply message to later be called as part of the sendWatchExtensionReply method.
2.The Ti.App.iOS event
This is the coordinator for all of the actions done within your Titanium application. The callback returns two properties, handlerId and userInfo (optional). The handlerId is the most important component in that it is the key to our NSDictionary with the reply block that needs to be called. The userInfo is optional, and includes the information passed from your WatchKit extension.
Ti.App.iOS.addEventListener("watchkitextensionrequest",function(e){
});
3.sendWatchExtensionReply
The sendWatchExtensionReply method is used to trigger the reply method from the delegate. This must be called or bad things happen. The sendWatchExtensionReply method has a required paramater of the handlerId, and an optional payload to return to the watch extension. The optional payload must be an object, not an array. If you need to pass an array, you must do so as a property of an object.
Example with all paramters
Ti.App.iOS.addEventListener("watchkitextensionrequest",function(e){
var myReplyContent = {foo:"bar"};
Ti.App.iOS.sendWatchExtensionReply(e.handlerId,myReplyContent);
});
Example with only handlerid
Ti.App.iOS.addEventListener("watchkitextensionrequest",function(e){
Ti.App.iOS.sendWatchExtensionReply(e.handlerId);
});