ios - 如何从 WatchKit 应用程序打开 iPhone 上的应用程序?

标签 ios watchkit

我在我的应用程序中使用 watchkit。我想通过watchkit在iphone中打开应用程序。我搜索了很多但找不到任何东西。任何帮助将不胜感激。

我也尝试过下面的链接 How can I open the parent app on iPhone from my WatchKit app?

最佳答案

如果您使用 Objective C,则只需将以下方法放入 AppDelegate.m 文件中即可。

- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void(^)(NSDictionary *replyInfo))reply {
    NSString * request = [userInfo objectForKey:@"requestString"];
    if ([request isEqualToString:@"executeMethodA"]) {
        // Do whatever you want to do when sent the message. For instance...
        //[self executeMethodABC];
    }
    reply(@{@"clicked from  watch":@(1)});
}

希望这对您有帮助。

关于ios - 如何从 WatchKit 应用程序打开 iPhone 上的应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36131148/

相关文章:

ios - 记录更新的 CloudKit 推送通知停止工作

ios - 为表格 View 单元格添加自定义字体

objective-c - 使用模态部分 curl ,我想反转动画。我该怎么做?

ios - 实例CoreData对象而不保存它

android - react native : Null is not an object - Push notification (OneSignal)

ios - iPhone 尝试制作一个年终倒计时器

swift - 如何在 SwiftUI 中为 Watchkit 注册前台通知?

ios - 如何在 iOS 中设置 Apple Watch 图标图像

ios - 可以检测我的框架是作为主应用程序还是扩展程序的一部分运行?

ios - "The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]"