Bug 42405 - WKInterfaceController.OpenParentApplication does not seem to be accessible
Summary: WKInterfaceController.OpenParentApplication does not seem to be accessible
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.WatchOS.dll ()
Version: XI 9.10 (C8)
Hardware: Macintosh Mac OS
: --- major
Target Milestone: (C7)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-07 18:13 UTC by chris hollander
Modified: 2016-07-07 21:03 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description chris hollander 2016-07-07 18:13:30 UTC
# Steps to reproduce
code does not compile when i attempt to call the static method OpenParentApplication on the WKInterfaceController class. returns CS0117 error (...does not contain a definition for...).

# Expected behavior
I expect to be able to call the static method ;)

# Actual behavior
failure to compile

# Supplemental info (logs, images, videos)

sample code:
using System;
using WatchKit;
using Foundation;
namespace ClockKing.RoutinelyExtension
{
	public partial class InterfaceController : WKInterfaceController
	{
		public override void WillActivate()
		{
			// This method is called when the watch view controller is about to be visible to the user.
			Console.WriteLine("{0} will activate", this);
			WKInterfaceController.OpenParentApplication(new NSDictionary(), (replyInfo, error) =>
			{
				if (error != null)
				{
					Console.WriteLine(error);
					return;
				}
				Console.WriteLine("parent app responded");
				// do something with replyInfo[] dictionary
			});
		}

# Test environment (full version information)

alpha channel.
Comment 1 Sebastien Pouliot 2016-07-07 19:32:25 UTC
That API exists but it's only available from iOS (if you run on the phone), i.e. not on watchOS (if you run on the watch). 

That's controlled by the WK_AVAILABLE_IOS_ONLY macro, e.g.

from iOS SDK

+ (BOOL)openParentApplication:(NSDictionary *)userInfo reply:(nullable void(^)(NSDictionary * replyInfo, NSError * __nullable error)) reply WK_AVAILABLE_IOS_ONLY(8.2);    // launches containing iOS application on 

and watchOS SDK

+ (BOOL)openParentApplication:(NSDictionary *)userInfo reply:(nullable void(^)(NSDictionary * replyInfo, NSError * __nullable error)) reply WK_AVAILABLE_IOS_ONLY(8.2);    // launches containing iOS application on the phone. userInfo must be non-nil


It looks like you should be using the WatchConnectivity namespace for this.
Comment 2 chris hollander 2016-07-07 20:08:26 UTC
Thank you for your quick response.  I Understand how the availability is being set; however, the examples in the xamarin guides suggest using this method from the watchkit extension:

https://developer.xamarin.com/guides/ios/watch/working-with/parent-app/

is this a deprecated behavior from watchkit 1.0?
Comment 3 Sebastien Pouliot 2016-07-07 20:36:44 UTC
It's not a deprecation, this is still available in WatchKit, as part of iOS but it does not exists in watchOS.

Apple made it a bit confusing but watchOS 1.x only support WatchKit _extensions_ (on phone). There's no such things as WatchKit 1.0 or 2.0, WatchKit is a framework that exists on both OS.

Also the linked guide is about WatchKit _extensions_, i.e. running on iOS (phone) and not watchOS 2.x (native apps on the watch device). As such it's normal (and correct) to use this API in this context.
Comment 4 chris hollander 2016-07-07 21:03:57 UTC
ah, ok, that makes (slightly?) more sense.  I'll look into WatchConnectivity, and i'll keep an eye out for an updated guide for using WatchKit on watchOS 2.x.