iOS 从 phone 切换到 macbook safari/chrome
iOS handoff from phone to macbook safari/chrome
我想从我的应用程序发送 URL 以使用切换在笔记本电脑网络浏览器上打开。我已将 activity 类型添加到我的应用程序的 NSUserActivityTypes
中。到目前为止,这是我的代码:
- (void)startHandoff {
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.me.browse"];
activity.webpageURL = [NSURL URLWithString:_wakeUrl];
[activity becomeCurrent];
}
它似乎没有出现在我的 dock 上 - 如果你想使用 safari,它需要一个特殊的 Activity Type
吗?
Ok 经过测试,看来您需要将 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.whosebug.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.whosebug.com"];
[activity becomeCurrent];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
不知道为什么,我现在正在调查
我想从我的应用程序发送 URL 以使用切换在笔记本电脑网络浏览器上打开。我已将 activity 类型添加到我的应用程序的 NSUserActivityTypes
中。到目前为止,这是我的代码:
- (void)startHandoff {
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.me.browse"];
activity.webpageURL = [NSURL URLWithString:_wakeUrl];
[activity becomeCurrent];
}
它似乎没有出现在我的 dock 上 - 如果你想使用 safari,它需要一个特殊的 Activity Type
吗?
Ok 经过测试,看来您需要将 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.whosebug.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.whosebug.com"];
[activity becomeCurrent];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
不知道为什么,我现在正在调查