Bug 44716 - WatchConnectivity: Payload could not be delivered.
Summary: WatchConnectivity: Payload could not be delivered.
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.WatchOS.dll ()
Version: XI 10.0 (iOS10)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-09-24 17:03 UTC by Shay
Modified: 2016-09-27 12:45 UTC (History)
4 users (show)

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


Attachments
Xamarin Project to reproduce the bug and log (26.16 KB, application/zip)
2016-09-24 17:03 UTC, Shay
Details


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 Shay 2016-09-24 17:03:24 UTC
Created attachment 17727 [details]
Xamarin Project to reproduce the bug and log

I am trying to use WatchConnectivity to send basic messages from the watch to the phone and back (WatchOS3, Target: 10). 
I'm getting errors on the watch of the form "Payload could not be delivered." (and sometimes "Timed out").
Parent app is running and reports that WCSession is paired and Application Is Installed.
Ways to reproduce:
Run the attached project. Click "Start" On watch (This will create the session), Run app on parent phone, Then Click "Send" On watch.

I am not sure whether I am doing something wrong, or this is an internal bug.
Basically, I created a delegate to handle messaging:

	public class WatchSessionManager : WCSessionDelegate
	{
		public WatchSessionManager()
		{
			base.Init();
			session = WCSession.DefaultSession;
		}
		private WCSession session;

		public void start()
		{
			session.Delegate = this;
			session.ActivateSession();
		}
		public override void DidReceiveMessage(WCSession session, NSDictionary<NSString, NSObject> message)
		{
			base.DidReceiveMessage(session, message);
			Console.WriteLine("Got message " + message.ToString());
		}

		public void sendMessage()
		{
			Console.WriteLine("Trying to send message...");
			if (session.Paired && session.WatchAppInstalled)
			{
				session.SendMessage("Hello", (replyMessage) =>
				{
					Console.WriteLine("Reply: " + replyMessage.ToString());
				}, (NSError obj) =>
				{
					Console.WriteLine("Error : " + obj.ToString());
				});
			}
		}

	}

I Call start(), and then sendMessage() and hope to get something back on the DidReceiveMessage function on the phone.


Full application output and Xamarin projects are attached.
Comment 1 Shay 2016-09-26 03:58:39 UTC
Added note:
I also tested session.Reachable, which returned true, so overall, all three (Paired, WatchAppInstalled, Reachable) are true, but I keep getting those payload error messages. I also tried to send a dictionary instead of the "Hello" string. That didn't work either.
Comment 2 ulrike_axen 2016-09-26 12:51:00 UTC
Shay, I am another Xamarin.ios user. I have a WatchConnectivity working pretty reliably, so I don't think this is a bug, although I encountered this earlier in my development. After you call "ActivateSession()", you have to wait for the callback in your WCSessionDelegate "ActivationDidComplete" before you can start sending messages.

If that doesn't work, then take this to the forum and I can try to help you further. I regularly send messages from the watch to the phone and get replies (and phone to watch) so there must just be a small thing missing. I also use the background updates when the watch app is not active. Hope this helps.
Comment 3 Shay 2016-09-26 22:28:11 UTC
Ulrike pointed me to an example project (https://bugzilla.xamarin.com/show_bug.cgi?id=44526) which works. This is probably an implementation bug from my side.
Thanks Ulrike!
Xamarin folks - please consider updating your online documentation on Parent App Communication. The online docs and examples only refer to WatchOS1 Wormhole-style communication.
Comment 4 Vincent Dondain [MSFT] 2016-09-27 12:44:56 UTC
Thanks Ulrike for the information, your contribution is very much appreciated.

Shay I relayed your comment to the documentation team so they can take actions. Thanks for the feedback.