Bug 8695 - Add Events for methods in UIApplication.SharedApplication
Summary: Add Events for methods in UIApplication.SharedApplication
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.1.x
Hardware: PC All
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-11-30 14:02 UTC by Redth
Modified: 2017-01-05 04:42 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 Redth 2012-11-30 14:02:22 UTC
It would be extremely useful if there were some events that can currently be overridden in the UIApplicationDelegate as methods.

Here's the additions I'd like to see:

UIApplication.SharedApplication.OnRegisteredForRemoteNotifications(UIApplication app, NSData deviceToken);
UIApplication.SharedApplication.OnFailedToRegisterForRemoteNotifications(UIApplication app, NSError error);
UIApplication.SharedApplication.ReceivedRemoteNotification(UIApplication app, NSDictionary userInfo);


These events should be fired whether or not the methods have been overridden in the AppDelegate.  

SharedApplication might not be the right spot for this, but what I'm getting at is needing a way to know these things have happened without being the delegate.

The main use case I have for this right now is trying to make an abstract 'client' library for PushSharp.  Currently, it would require users of the library to use my own implementation of UIApplicationDelegate.  This may be ok for some, but once you start using things like MvvmCross, etc., you would be competing for which implementation of UIApplicationDelegate to use...

Is this a possibility, or anything similar?
Comment 1 Redth 2012-11-30 14:23:16 UTC
Not sure why I didn't think of this earlier, but perhaps an easier way would be for MonoTouch to under the hood post a notification to the NSNotificationCenter.DefaultCenter with a particular name... eg:

NSNotificationCenter.DefaultCenter.PostNotificationName("UIApplicationDelegate.RegisteredForRemoteNotifications", deviceToken);

NSNotificationCenter.DefaultCenter.PostNotificationName("UIApplicationDelegate.FailedToRegisterForRemoteNotifications", error);

NSNotificationCenter.DefaultCenter.PostNotificationName("UIApplicationDelegate.ReceivedRemoteNotification", userInfo);


This way the notifications could be easily consumed by any library, including a PushSharp client...
Comment 2 Alex Soto [MSFT] 2017-01-05 04:42:58 UTC
The way this works is to subscribe to the notification you want to hear about, but we "Xamarin.iOS" have no reason to fire these events ourselves so we can't really bake this on our side