Bug 29863 - UIApplicationRestorationHandler params must export "restoreUserActivityState:" not just NSObject
Summary: UIApplicationRestorationHandler params must export "restoreUserActivityState:...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.7.x (iOS 8.2 previews)
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-05-07 17:11 UTC by Larry O'Brien
Modified: 2017-08-29 18:19 UTC (History)
4 users (show)

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:

Description Larry O'Brien 2015-05-07 17:11:28 UTC
According to https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/Handoff/HandoffFundamentals/HandoffFundamentals.html :

"The application:continueUserActivity:restorationHandler: message includes a block, the restoration handler, that you can optionally call if your app uses auxiliary responder or document objects to perform the resuming user activity. Create these objects (or fetch them if cached) and pass them to the restoration handler in its NSArray parameter. The system then sends each object a restoreUserActivityState: message, passing the user activity object."

Both `UIDocument` and `UIResponder` have a `RestoreUserActivityState` method, but they do not have a common interface (`IRestoreUserActivityState` or somesuch).

(By experimentation, it appears to me that nothing bad happens even if the handler is called with objects that do not export `restoreUserActivityState:` so I've set the priority to 'minor'.)
Comment 1 Miguel de Icaza [MSFT] 2015-05-18 12:49:16 UTC
Larry, I do not understand the bug report.

You talk about "continueWithUserActivity", and then talk about restoration.

Can you explain and reopen?
Comment 2 Larry O'Brien 2015-05-19 18:29:38 UTC
The `UIDocumentOrResponderObjects` parameter to the `UIApplicationRestorationHandler` is currently an array of `NSObject`s (this matches the Obj-C / Swift signature). But, in fact, that handler sends the message `restoreUserActivityState:` to each object:

    public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
			System.Console.WriteLine ("Continue received");
			var auxiliaryResponders = new NSObject[] {
				new UIViewControllerSubtype(),
				new RestoreUserActivityStateExporter(),
				new DoesNotExportRestoreUserActivityState()
			completionHandler (auxiliaryResponders);
			return true;

class UIViewControllerSubtype : UIViewController 
	public override void RestoreUserActivityState (NSUserActivity activity)
		System.Console.WriteLine ("UIViewControllerSubtype.RestoreUserActivityState");
class RestoreUserActivityStateExporter : NSObject
	[Export ("restoreUserActivityState:")]
	public void RestoreUserActivityState(NSUserActivity userActivity)
		System.Console.WriteLine ("RestoreUserActivityStateExporter.RestoreUserActivityState");

class DoesNotExportRestoreUserActivityState : NSObject
	public void RestoreUserActivityState(NSUserActivity userActivity)
		System.Console.WriteLine("DoesNotExportUserActivityState.RestoreUserActivityState <-- NOT EXECUTED, OF COURSE");

Results in :
May 19 12:16:55 Larrys-iPhone HandoffDemo[745] <Warning>: Continue received
May 19 12:16:55 Larrys-iPhone HandoffDemo[745] <Warning>: UIViewControllerSubtype.RestoreUserActivityState
May 19 12:16:55 Larrys-iPhone HandoffDemo[745] <Warning>: RestoreUserActivityStateExporter.RestoreUserActivityState

No exception seems to be generated by passing in an `NSObject` that does not export `restoreUserActivityState:` (a la `DoesNotExportRestoreUserActivityState` type above) 
so there does not appear to be harm having the type remain an `NSObject[]` *but* perhaps the signature would be better if there were a `IRestoreUserActivityState` interface
defined as exporting the selector.
Comment 3 John Miller [MSFT] 2017-07-26 18:16:48 UTC

I attempted to reproduce this issue based on the bug description with the latest Xamarin.iOS, and I was unable to hit the problem. If this issue is still occurring for you, please update this report and attach a project that reproduces the issue, ideally starting with a new template project and then adding just the code necessary to demonstrate the issue.

I am going to move this to NEEDINFO and label it an enhancement based on the suggestion to use something like IRestoreUserActivityState instead.
Comment 4 Vincent Dondain [MSFT] 2017-08-29 18:19:21 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and re-open the bug report. Thanks!