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 (show other bugs)
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)

See Also:
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

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

Note You need to log in before you can comment on or make changes to this bug.