![]() Var navigation = Īwait navigation.PushModalAsync(new ModalPage(e.AppAction.Title)) ![]() OnAppAction -= app.AppActions_OnAppAction If (Application.Current != this & Application.Current is App app) ![]() and cleanup the old instance's event handler Don't handle events fired for old application instances The AppActions_OnAppAction will look like this: private void AppActions_OnAppAction(object sender, AppActionEventArgs e) Right under InitializeComponent(), we’ll add this: .OnAppAction += AppActions_OnAppAction In this example we’ll be navigating to a modal page with the title of the action as a parameter.įirst we need to register for the OnAppAction event. navigate the user into a specific part of the app or maybe pre-fill some input for common actions. Now onto the actual handling of the actions. This image is retrieved from Resources -> Images in my project. The first action has an id of id1, a display title of “Messages” and uses the image messages.png as icon. In the following example I have added three actions: This is already used in your MauiProgram class and you can extend it by using the ConfigureEssentials-method. You can add your app actions using the MauiAppBuilder. Your AppDelegate should look like this: Adding actions => Platform.PerformActionForShortcutItem(application, shortcutItem, completionHandler) This is located under Platforms -> iOS.Īdd the following logic under the CreateMauiApp-method: public override void PerformActionForShortcutItem(UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler) Your MainActivity should look like this: iOS setupįor iOS we also need to set some things up in our AppDelegate class. Protected override void OnNewIntent( intent) You also need to add this logic to handle the actions: protected override void OnResume() NET MAUI, this class is located under Platforms -> Android.Īdd the following intent filter to your class, right above the Activity attribute: )] Android setupįirst we need to set up some things in our MainActivity class. NET MAUI Essentials, so you don’t need to bring in any extra packages. You can use them if you want to provide shortcuts for your user to easily navigate into a specific part of your app. App actions are those shortcuts that pop up when you long press on your app’s icon. In this post I’ll be showing you how to use app actions in your.
0 Comments
Leave a Reply. |