This gist outlines how to use an experimental build of the Ti SDK that includes the delegate needed for openParentApplication support
Steps:
- Download the latest master nightly build
- You need to replace the following four files in your nightly build with the ones listed below
https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiApp.h https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiApp.m https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiAppiOSProxy.m https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiBase.h https://github.com/benbahrenburg/titanium_mobile/blob/ca8083c3a99fd017a6656f33f2c99e0d7118c65c/iphone/Classes/TiBase.m
- Now you are ready to start to test
Testing:
- First in your Ti app, you need to add the listener
Ti.App.iOS.addEventListener("watchkitextensionrequest",function(e){
});
This will be fired when your watchkit extension makes a request.
- Next you will need to make sure you provide a reply once the event is fired.
Ti.App.iOS.addEventListener("watchkitextensionrequest",function(e){
var myReplyContent = [{foo:"bar"}];
Ti.App.iOS.sendWatchExtensionReply(e.handlerId,myReplyContent);
});
This will send the result back to your watch. Bad things will happen if you don't send a reply message. If you don't have any reply content you can just skip that parameter, as soon below.
Ti.App.iOS.addEventListener("watchkitextensionrequest",function(e){
Ti.App.iOS.sendWatchExtensionReply(e.handlerId);
});
The most important thing to provide is the handlerId that is included within the event callback. This is the reference Titanium needs to issue the reply.
- You are now ready to add a WKInterfaceController.openParentApplication statement into your Watch Extension and try it out.
In theory, this should all just work, but I haven't had a chance to test out the full cycle or each of the corners.