Compare commits

..

No commits in common. "master" and "v0.0.3" have entirely different histories.

5 changed files with 15 additions and 38 deletions

7
RNHandoff.android.js Normal file
View File

@ -0,0 +1,7 @@
import { Component } from 'react';
export default class Handoff extends Component {
render() {
return null;
}
}

View File

@ -1,19 +1,19 @@
import { PureComponent } from 'react';
import { Component } from 'react';
import { NativeModules } from 'react-native'
const { RNHandoff } = NativeModules;
let id = 0;
export default class Handoff extends PureComponent {
export default class Handoff extends Component {
id = -1;
componentDidMount() {
const { type, title, userInfo, url } = this.props;
componentWillMount() {
const { type, title, url } = this.props;
this.id = ++id;
RNHandoff.becomeCurrent(this.id, type, title, userInfo, url);
RNHandoff.becomeCurrent(this.id, type, title, url);
}
componentWillUnmount() {

View File

@ -1,7 +0,0 @@
import { PureComponent } from 'react'
export default class Handoff extends PureComponent {
render() {
return null
}
}

View File

@ -1,19 +0,0 @@
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

View File

@ -12,16 +12,12 @@ NSMutableArray *activities = nil;
return activities;
}
RCT_EXPORT_METHOD(becomeCurrent:(NSNumber * _Nonnull)activityId type:(NSString *)type title:(NSString *)title userInfo:(NSDictionary *)userInfo url:(NSString *)url)
RCT_EXPORT_METHOD(becomeCurrent:(NSNumber * _Nonnull)activityId type:(NSString *)type title:(NSString *)title url:(NSString *)url)
{
NSUserActivity* activity = [[NSUserActivity alloc] initWithActivityType:type];
activity.title = title;
activity.eligibleForHandoff = YES;
if(!([[url stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0)) {
activity.webpageURL = [NSURL URLWithString:url];
} else {
activity.userInfo = userInfo;
}
activity.webpageURL = [[NSURL alloc] initWithString:url];
[activity becomeCurrent];
[[self activityList] addObject:@{ @"id": activityId, @"activity": activity }];