Search code examples
ioscocoa-touchwatchkitapple-watch

Is it possible to open your iPhone App using the Apple Watch?


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.


Solution

  • 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.