首页 > 解决方案 > (3D touch) 当用户杀死应用程序时,如何在应用程序中打开特定页面?

问题描述

我正在使用3D Touch 和快速操作导航到我的应用程序中的“搜索”页面。

我在AppDelegate.cs:的方法PerformActionForShortcutItem()处处理事件单击快捷方式按钮:

    public override void PerformActionForShortcutItem(UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler)
    {
        bool handledShortCutItem = HandleShortCutItem(shortcutItem);
        completionHandler(handledShortCutItem);
    }
 MessagingCenter.Send(new SearchContactEventMessage(), nameof(SearchContactEventMessage));
MessagingCenter.Subscribe<SearchContactEventMessage>(this, nameof(SearchContactEventMessage), message =>

    {

        // TODO Open page Search in my app 
        .....
    }

当我的应用程序在前台或后台运行时,它可以工作(可以打开“搜索”页面)。

如果我的应用程序未打开或用户将其杀死,则无法显示“搜索”页面。

当用户“杀死”应用程序并使用“快速操作”时,可以给我一个想法,我的应用程序可以在应用程序中显示某个页面。

标签: xamarinxamarin.formsxamarin.ios

解决方案


原因:

一旦您单击并发送MessagingCenter当用户“杀死”应用程序时MainPageViewModel.cs,它就没有订阅您的应用程序,MessagingCenter因为您的应用程序已终止。因此,它不会MessagingCenter在您的应用中接收和打开页面搜索。

解决方案:

我建议您直接在handledShortCutItem方法中打开搜索页面。


推荐阅读