Add url parameter
This commit is contained in:
parent
951497c678
commit
31d005f93d
@ -9,11 +9,11 @@ export default class Handoff extends PureComponent {
|
||||
id = -1;
|
||||
|
||||
componentDidMount() {
|
||||
const { type, title, userInfo } = this.props;
|
||||
const { type, title, userInfo, url } = this.props;
|
||||
|
||||
this.id = ++id;
|
||||
|
||||
RNHandoff.becomeCurrent(this.id, type, title, userInfo);
|
||||
RNHandoff.becomeCurrent(this.id, type, title, userInfo, url);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@ -12,12 +12,16 @@ NSMutableArray *activities = nil;
|
||||
return activities;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(becomeCurrent:(NSNumber * _Nonnull)activityId type:(NSString *)type title:(NSString *)title userInfo:(NSDictionary *)userInfo)
|
||||
RCT_EXPORT_METHOD(becomeCurrent:(NSNumber * _Nonnull)activityId type:(NSString *)type title:(NSString *)title userInfo:(NSDictionary *)userInfo url:(NSString *)url)
|
||||
{
|
||||
NSUserActivity* activity = [[NSUserActivity alloc] initWithActivityType:type];
|
||||
activity.title = title;
|
||||
activity.userInfo = userInfo;
|
||||
activity.eligibleForHandoff = YES;
|
||||
if(!([[url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0)) {
|
||||
activity.webpageURL = [NSURL URLWithString:url];
|
||||
} else {
|
||||
activity.userInfo = userInfo;
|
||||
}
|
||||
[activity becomeCurrent];
|
||||
|
||||
[[self activityList] addObject:@{ @"id": activityId, @"activity": activity }];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user