UIApplication.Notifications.ObserveDidFinishLaunching Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Surcharges
ObserveDidFinishLaunching(EventHandler<UIApplicationLaunchEventArgs>) |
Notification fortement typée pour la DidFinishLaunchingNotification constante. |
ObserveDidFinishLaunching(NSObject, EventHandler<UIApplicationLaunchEventArgs>) |
Notification fortement typée pour la DidFinishLaunchingNotification constante. |
ObserveDidFinishLaunching(EventHandler<UIApplicationLaunchEventArgs>)
Notification fortement typée pour la DidFinishLaunchingNotification constante.
public static Foundation.NSObject ObserveDidFinishLaunching (EventHandler<UIKit.UIApplicationLaunchEventArgs> handler);
static member ObserveDidFinishLaunching : EventHandler<UIKit.UIApplicationLaunchEventArgs> -> Foundation.NSObject
Paramètres
- handler
- EventHandler<UIApplicationLaunchEventArgs>
Méthode à appeler lorsque la notification est publiée.
Retours
Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)
Remarques
L’exemple suivant montre comment les développeurs peuvent utiliser cette méthode dans leur code :
//
// Lambda style
//
// listening
notification = UIApplication.Notifications.ObserveDidFinishLaunching ((sender, args) => {
/* Access strongly typed args */
Console.WriteLine ("Notification: {0}", args.Notification);
Console.WriteLine ("Url", args.Url);
Console.WriteLine ("SourceApplication", args.SourceApplication);
Console.WriteLine ("RemoteNotifications", args.RemoteNotifications);
Console.WriteLine ("LocationLaunch", args.LocationLaunch);
});
// To stop listening:
notification.Dispose ();
//
//Method style
//
NSObject notification;
void Callback (object sender, UIKit.UIApplicationLaunchEventArgs args)
{
// Access strongly typed args
Console.WriteLine ("Notification: {0}", args.Notification);
Console.WriteLine ("Url", args.Url);
Console.WriteLine ("SourceApplication", args.SourceApplication);
Console.WriteLine ("RemoteNotifications", args.RemoteNotifications);
Console.WriteLine ("LocationLaunch", args.LocationLaunch);
}
void Setup ()
{
notification = UIApplication.Notifications.ObserveDidFinishLaunching (Callback);
}
void Teardown ()
{
notification.Dispose ();
}
S’applique à
ObserveDidFinishLaunching(NSObject, EventHandler<UIApplicationLaunchEventArgs>)
Notification fortement typée pour la DidFinishLaunchingNotification constante.
public static Foundation.NSObject ObserveDidFinishLaunching (Foundation.NSObject objectToObserve, EventHandler<UIKit.UIApplicationLaunchEventArgs> handler);
static member ObserveDidFinishLaunching : Foundation.NSObject * EventHandler<UIKit.UIApplicationLaunchEventArgs> -> Foundation.NSObject
Paramètres
- objectToObserve
- NSObject
Objet à observer.
- handler
- EventHandler<UIApplicationLaunchEventArgs>
Méthode à appeler lorsque la notification est publiée.
Retours
Objet jeton qui peut être utilisé pour arrêter de recevoir des notifications en le supprimant ou en le transmettant à RemoveObservers(IEnumerable<NSObject>)
Remarques
Cette méthode peut être utilisée pour DidFinishLaunchingNotification s’abonner aux notifications.
// Listen to all notifications posted for any object
var token = UIApplication.Notifications.ObserveDidFinishLaunching ((notification) => {
Console.WriteLine ("Observed DidFinishLaunchingNotification!");
};
// Listen to all notifications posted for a single object
var token = UIApplication.Notifications.ObserveDidFinishLaunching (objectToObserve, (notification) => {
Console.WriteLine ($"Observed DidFinishLaunchingNotification for {nameof (objectToObserve)}!");
};
// Stop listening for notifications
token.Dispose ();