Sirikit and parent app communication in ios 10 : Handoff

依然范特西╮ 提交于 2019-12-11 23:18:17

问题


I am using Sirikit to integrate with my payment domain app where I need to interact with the app. I read Apple documentation, they asked to use common frameworks. Is it possible to use handoff? if yes then how? How can I call the other viewController which is in parent app from sirikit?

I will really appreciate for any help. Thanks


回答1:


Check SiriKit Programming Guide,

To use handoff, You can create intent response object with NSUserActivity object. While creating NSUserActivity object assign userInfo property to appropriate object that you want,

let userActivity = NSUserActivity()
userActivity.userInfo = ["myKey": myAnyObject]

You will get this NSUserActivity object in parent application AppDelegate,

optional public func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: ([AnyObject]?) -> Swift.Void) -> Bool

Here you can get userInfo object which you can compare as per your requirement and call appropriate viewController.




回答2:


Every user activity object needs a type and we need to define those types in the

info.plist of the application

For Eg.

let userActivity = NSUserActivity(activityType: "uaType")
userActivity.title = "uaTitle"
userActivity.userInfo = ["uaKey": "uaValue"]

You can now access this activity object in AppDelegate as follows

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {

        switch userActivity.activityType {
        case "uaType": 
        //Write your logic to access uaKey & uaValue here
        return true
        default: return false
        }
}


来源:https://stackoverflow.com/questions/38417719/sirikit-and-parent-app-communication-in-ios-10-handoff

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!