2

I want to show a quick summary of text the user receives on their Apple Watch. Then, they can read the rest of the text on their iPhone by clicking on a button inside the iWatch App. I do not think this is currently possible, but if it is please let me know what I need to do in order to accomplish this.

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Danger Veger
  • 1,117
  • 1
  • 9
  • 16
  • Handoff to work, your Apple Watch must be connected to your paired iPhone. Refer this link - https://support.apple.com/en-in/guide/watch/apdc40081790/watchos – Chid Mar 12 '20 at 15:36

3 Answers3

3

You can open your iOS app in the background with

+ (BOOL)openParentApplication:(NSDictionary *)userInfo
                        reply:(void (^)(NSDictionary *replyInfo,
                                        NSError *error))reply

Your iOS app will get

- (void)application:(UIApplication *)application
handleWatchKitExtensionRequest:(NSDictionary *)userInfo
              reply:(void (^)(NSDictionary *replyInfo))reply

So if your iOS app is already running you can use this to give the information to the app. However, you can't make your iOS app run in the foreground, that must be initiated by the user. You can save the rest of the text to the shared settings and/or pass it to your app in the background with openParentApplication. Then when the user opens your iOS app you can show them the rest of the text.

Stephen Johnson
  • 5,293
  • 1
  • 23
  • 37
1

No it is not possible to open your App on the iPhone through the Watch, BUT you can open your app in background.

Lets say you want to view news on your watch, and for that you need data. You get that data through the iPhone app with: openParentApplication: and handleWatchKitExtensionRequest:

How to do that is explained in this answer: How to send data from iphone to watchkit in swift

Community
  • 1
  • 1
Dejan Skledar
  • 11,280
  • 7
  • 44
  • 70
1

If you need to open your parent app in the foreground, use Handoff!

https://developer.apple.com/handoff/

Example:

Somewhere shared for both:

static let sharedUserActivityType = "com.yourcompany.yourapp.youraction"
static let sharedIdentifierKey = "identifier"

on your Watch:

updateUserActivity(sharedUserActivityType, userInfo: [sharedIdentifierKey : 123456], webpageURL: nil)

on your iPhone in App Delegate:

func application(application: UIApplication, willContinueUserActivityWithType userActivityType: String) -> Bool {
    if (userActivityType == sharedUserActivityType) {
        return true
    }
    return false
}

func application(application: UIApplication, continueUserActivity userActivity: NSUserActivity, restorationHandler: ([AnyObject]!) -> Void) -> Bool {
    if (userActivity.activityType == sharedUserActivityType) {
        if let userInfo = userActivity.userInfo as? [String : AnyObject] {
            if let identifier = userInfo[sharedIdentifierKey] as? Int {
                //Do something
                let alert = UIAlertView(title: "Handoff", message: "Handoff has been triggered for identifier \(identifier)" , delegate: nil, cancelButtonTitle: "Thanks for the info!")
                alert.show()
                return true
            }
        }
    }
    return false
}

And finally (this step is important!!!): In your Info.plist(s)

enter image description here

stk
  • 6,311
  • 11
  • 42
  • 58