简体   繁体   中英

iOS Corespotlight search: When app is not running

When the app is running, the continueUserActivity method gets called in which I handle the deep linking into the right location. However, when the app is not running, this function never gets called. I believe in the case when the app is not running, the call goes into application:didFinishLaunchingWithOptions: .

public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
{
        if (userActivity.UserInfo.ContainsKey(CSSearchableItem.ActivityIdentifier))
        {
            // do stuff to handle deep link
        }
}

The above implementation works fine when the app is backgrounded, but when I kill it the search results no longer deep link correctly.

Any clue on how to handle this in application:didFinishLaunchingWithOptions: ? Is there a way to tell if the app is launched from a corespotlight search item specifically?

I just checked in my app by adding an alert to both methods.

When the app is running only the continuation method is called. When the app is not running both methods will be called.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM