Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31d005f93d | ||
|
|
951497c678 | ||
|
|
f5becc63f3 | ||
|
|
05fc7dee38 | ||
|
|
b9e42ec4c4 | ||
|
|
8978fac41a |
@ -1,7 +0,0 @@
|
||||
import { Component } from 'react';
|
||||
|
||||
export default class Handoff extends Component {
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,19 @@
|
||||
import { Component } from 'react';
|
||||
import { PureComponent } from 'react';
|
||||
import { NativeModules } from 'react-native'
|
||||
|
||||
const { RNHandoff } = NativeModules;
|
||||
|
||||
let id = 0;
|
||||
|
||||
export default class Handoff extends Component {
|
||||
export default class Handoff extends PureComponent {
|
||||
id = -1;
|
||||
|
||||
componentWillMount() {
|
||||
const { type, title, url } = this.props;
|
||||
componentDidMount() {
|
||||
const { type, title, userInfo, url } = this.props;
|
||||
|
||||
this.id = ++id;
|
||||
|
||||
RNHandoff.becomeCurrent(this.id, type, title, url);
|
||||
RNHandoff.becomeCurrent(this.id, type, title, userInfo, url);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
7
RNHandoff.js
Normal file
7
RNHandoff.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { PureComponent } from 'react'
|
||||
|
||||
export default class Handoff extends PureComponent {
|
||||
render() {
|
||||
return null
|
||||
}
|
||||
}
|
||||
19
RNHandoff.podspec
Normal file
19
RNHandoff.podspec
Normal file
@ -0,0 +1,19 @@
|
||||
require 'json'
|
||||
|
||||
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "RNHandoff"
|
||||
s.version = package['version']
|
||||
s.summary = "React Native Handoff support for iOS"
|
||||
|
||||
s.homepage = "https://github.com/IzaakSultan/react-native-handoff"
|
||||
s.author = "IzaakSultan"
|
||||
s.license = "MIT"
|
||||
s.platform = :ios, "9.0"
|
||||
|
||||
s.source = { :git => "https://github.com/IzaakSultan/react-native-handoff.git", :tag => s.version.to_s }
|
||||
s.source_files = "ios/**/*.{h,m}"
|
||||
|
||||
s.dependency 'React'
|
||||
end
|
||||
@ -12,12 +12,16 @@ NSMutableArray *activities = nil;
|
||||
return activities;
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(becomeCurrent:(NSNumber * _Nonnull)activityId type:(NSString *)type title:(NSString *)title url:(NSString *)url)
|
||||
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.webpageURL = [[NSURL alloc] initWithString:url];
|
||||
|
||||
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