0

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

Dhaval Panchal
  • 2,529
  • 1
  • 25
  • 36

2 Answers2

1

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
        }
}
0

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.

Dhaval Panchal
  • 2,529
  • 1
  • 25
  • 36
  • Thanks Dhawal for your explanation. I also tried the same. But, the handoff is not happening seamlessly. It is giving "open app" button. once you click the button, it will open the app. – chitranjan deo Jul 22 '16 at 04:19
  • @Dhawal.. The SiriKit sample code is saying "Page Not Found". How to fetch data from parent application from the IntentUI extension with out navigating? – Bharath Sep 20 '16 at 09:39