Bug 59928 - SKCloudServiceSetupViewController.LoadAsync() does not work correctly when passed an SKCloudServiceSetupOptions object instead of a manually-created NSDictionary
Summary: SKCloudServiceSetupViewController.LoadAsync() does not work correctly when pa...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 11.0 (xcode9)
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: xcode9.2
Assignee: Vincent Dondain [MSFT]
Depends on:
Reported: 2017-10-03 16:42 UTC by bradley.umbaugh
Modified: 2017-11-14 15:21 UTC (History)
2 users (show)

Is this bug a regression?: No
Last known good build:

Sample app demonstrating the bug (see: ViewController.cs). (11.54 KB, application/zip)
2017-10-03 16:42 UTC, bradley.umbaugh

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:

Description bradley.umbaugh 2017-10-03 16:42:40 UTC
Created attachment 25077 [details]
Sample app demonstrating the bug (see: ViewController.cs).

Attempting to build a sample MusicKit app.

The SKCloudServiceViewController.LoadAsync() method requires either an NSDictionary of options, or an instance of SKCloudServiceSetupOptions. Either way, I'm trying to pass in a subscribe action.

If I supply an NSDictionary and populate it as I see it populated in Apple's "Interacting with Apple Music Content" sample (linked on this page: https://developer.apple.com/musickit/) -- with key "SKCloudServiceSetupOptionsActionKey" and value "sdkSubscribe" -- SKCloudServiceViewController.LoadAsync() works as expected.

However an error is returned ("Cloud service setup view controller requires an action as part of the options for the load command") if I use the SKCloudServiceSetupOptions object, as below:

   var optionsObject = new SKCloudServiceSetupOptions();
   optionsObject.Action = SKCloudServiceSetupAction.Subscribe;
   (bool result, NSError error) = await cloudServiceSetupController.LoadAsync(optionsObject);n
   NSDictionary dict = optionsObject.Dictionary;

Inspecting optionsObject.Dictionary shows that it has key "SKCloudServiceSetupOptionsActionKey" and value 0.

Sample app attached, version information below.


=== Visual Studio Community 2017 for Mac ===

Version 7.1.5 (build 2)
Installation UUID: 27ed0702-4e75-4dec-96e5-2ec5e79bfd38
	Mono (d15-3/14f2c81) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 502000224

=== NuGet ===


=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks
SDK Versions:
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.5.5
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 9.0 (13247)
Build 9A235

=== Xamarin.iOS ===

Version: (Visual Studio Community)
Hash: 152b654a
Branch: xcode9
Build date: 2017-09-15 02:25:56-0400

=== Xamarin.Android ===

Version: (Visual Studio Community)
Android SDK: /Users/bradumbaugh/Library/Android/sdk
	Supported Android versions:
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
		7.1   (API level 25)

SDK Tools Version: 26.0.2
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 25.0.2

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)

Android Designer EPL code available here:

=== Xamarin Inspector ===

Version: 1.3.1
Hash: cbc48dd
Branch: 1.3-release
Build date: Thu, 21 Sep 2017 19:52:53 GMT
Client compatibility: 1

=== Xamarin.Mac ===

Version: (Visual Studio Community)

=== Build Information ===

Release ID: 701050002
Git revision: 7afedcaef8e7542e70e3cf8f9bdb26938b8c0876
Build date: 2017-09-15 08:39:58-04
Xamarin addins: 3262aadf811a18c12eac6742532d052b0139a808
Build lane: monodevelop-lion-d15-3-xcode9

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jun 15 17:36:27 PDT 2017
    root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
Comment 1 Vincent Dondain [MSFT] 2017-10-03 22:13:50 UTC

I can confirm this bug.

In the `SKCloudServiceSetupOptions` [StrongDictionary] we assign the smart enum value to the `SKCloudServiceSetupOptionsActionKey` constant.


That leads to the `SKCloudServiceSetupOptionsActionKey = 0` you saw.

We should assign the smart enum's **constant** instead.

Note: `SKCloudServiceSetupAction.Subscribe.GetConstant () == "sdkSubscribe"`

You found the right workaround though, what you can do is this:

var optionsDictionary = new NSDictionary (
	new NSString ("SKCloudServiceSetupOptionsActionKey"),
	       SKCloudServiceSetupAction.Subscribe.GetConstant ()

And use `public virtual Task<Tuple<bool, NSError>> LoadAsync (NSDictionary options);`
Comment 2 Vincent Dondain [MSFT] 2017-11-13 04:03:44 UTC