gpt4 book ai didi

iOS 从 iphone 切换到 macbook safari/chrome

转载 作者:搜寻专家 更新时间:2023-10-30 20:15:53 25 4
gpt4 key购买 nike

我想从我的应用程序发送一个 URL,以便使用 handoff 在笔记本电脑网络浏览器上打开。我已将事件类型添加到我的应用程序的 NSUserActivityTypes。到目前为止,这是我的代码:

- (void)startHandoff {
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.me.browse"];
activity.webpageURL = [NSURL URLWithString:_wakeUrl];
[activity becomeCurrent];
}

它似乎没有出现在我的 dock 上 - 如果您想使用 safari,是否需要特殊的 Activity Type

最佳答案

好的,经过测试,您似乎需要将 NSUserActivity 声明为实例变量:

所以这是行不通的:

@interface TestViewController () {
}

@end

@implementation TestViewController

- (void)viewDidLoad {
[super viewDidLoad];
//init hand off
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.app.browse"];
activity.webpageURL = [NSURL URLWithString:@"http://www.stackoverflow.com"];
[activity becomeCurrent];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

但这工作正常:

@interface TestViewController () {
NSUserActivity *activity;
}

@end

@implementation TestViewController

- (void)viewDidLoad {
[super viewDidLoad];
//init hand off
activity = [[NSUserActivity alloc] initWithActivityType:@"com.app.browse"];
activity.webpageURL = [NSURL URLWithString:@"http://www.stackoverflow.com"];
[activity becomeCurrent];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

不知道为什么,我现在正在研究它

关于iOS 从 iphone 切换到 macbook safari/chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30592960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com