Git Product home page Git Product logo

react-native-activity-view's Introduction

React Native Activity View

npm version npm downloads Code Climate

React Native Activity View is a React Native library for displaying iOS share and action sheets.

react-native-activity-view

Documentation

Install

npm i --save react-native-activity-view

Usage

Linking the Library

In order to use Activity View, you must first link the library to your project. There's excellent documentation on how to do this in the React Native Docs.

Show the Activity View

Once you've linked the library, you'll want to make it available to your app by requiring it:

var ActivityView = require('react-native-activity-view');

Showing the ActivityView is as simple as calling:

ActivityView.show({
  text: "Text you want to share",
  url: "URL you want to share",
  imageUrl: "Url of the image you want to share/action",
  imageBase64: "Raw base64 encoded image data"
  image: "Name of the image in the app bundle",
  file: "Path to file you want to share",
  exclude: ['postToFlickr'],
  anchor: React.findNodeHandle(this.refs.share), // Where you want the share popup to point to on iPad
});

Note:

  • Only provide one image type to the options argument. If multiple image types are provided, image will be used.
  • anchor is optional and only applicable for iPad. Popup will be centered by default if anchor is not provided.
  • exclude is an array with activities you want to exclude from activity view. See Apple's Documentation on Built-in Activity Types for a full list of available values. Note: pass only camelcased activity name, e.g. in order to exclude UIActivityTypePostToFlickr, pass postToFlickr etc.

Example

Using Activity View in your app will usually look like this:

var ActivityView = require('react-native-activity-view');

var YourComponent = React.createClass({
  _pressHandler() {
    ActivityView.show({
      text: 'ActivityView for React Native',
      url: 'https://github.com/naoufal/react-native-activity-view',
      imageUrl: 'https://facebook.github.io/react/img/logo_og.png',
      anchor: React.findNodeHandle(this.refs.share),
    });
  },

  render() {
    return (
      <View>
        ...
        <TouchableHighlight
          onPress={this._pressHandler}
        />
          <Text ref="share">
            Share with Activity View
          </Text>
        </TouchableHighlight>
      </View>
    );
  }
});

Methods

show(shareObject)

Displays the Activity View with actions relevant to the shareObject passed.

Arguments

  • shareObject - An Object containing one or more of the following keys text, url, anchor, exclude, imageUrl, imageBase64, or image.

Examples

ActivityView.show({
  text: 'ActivityView for React Native',
  url: 'https://github.com/naoufal/react-native-activity-view',
  imageUrl: 'https://facebook.github.io/react/img/logo_og.png',
  exclude: ['postToFlickr', 'airDrop'],
  anchor: React.findNodeHandle(this.refs.share),
});
ActivityView.show({
  text: 'ActivityView for React Native',
  imageBase64: 'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2...', 
  exclude: ['airDrop'],
  anchor: React.findNodeHandle(this.refs.share),
});

License

Copyright (c) 2015, Naoufal Kadhom

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

react-native-activity-view's People

Contributors

blakewilliams avatar chirag04 avatar danlafeir avatar grabbou avatar jberendes avatar naoufal avatar ryancoughlin avatar shaharz avatar wootwoot1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-activity-view's Issues

remove platform specific reference in package.json

I wasn't able to compile cross platform, and then I noticed in package.json, line 10, it says

"main": "ActivityView.ios.js",

shouldn't it be:

“main": "ActivityView”,

"React Native will detect when a file has a .ios. or .android. extension and load the right file for each platform when requiring them from other components." See:
https://facebook.github.io/react-native/docs/platform-specific-code.html#platform-specific-extensions

Once I made the latter change, it compiled cross platform. This should be trivial to fix. I can create a pull request if you like.

Unable to resolve module invariant

After updating to 0.2.5 I get this error from the packager: Unable to resolve module invariant from ActivityView.ios.js

This is with React Native 0.11.0

This application is modifying the autolayout engine from a background thread

After updating xcode last night, this no longer works as expected:

When you call ActivityView.show, it throws a TON of warnings/errors in the log:

screen shot 2015-09-18 at 7 28 45 am

After a delay of a few seconds while the console chugs through these messages, the share dialog appears, but its blank:

screen shot 2015-09-18 at 7 32 34 am

Let me know if I can provide any other details to help debug

Error sharing with Pinterest

Please, can you help me with this error, I am sending this object in the activity view

ActivityView.show ({
   Text: 'ActivityView for React Native',
   Url: 'shareLink'
   ImageUrl: 'https://facebook.github.io/react/img/logo_og.png',
);

And when I press share with pinterest it does not open anything, if I send it without the imageUrl it tells me that it did not find the element inside pinterest.

React Native 0.25.1 does not work

Hello, i already follow your installation, when i clicked to call activity view, not show anymore.
how should i configure ? i installed Version 0.2.10 and my react native version is 0.25.1

URL doesn't get passed to Notes

I have having notes in there, but it appears I can't exclude it because of iOS, so at the very least it would be nice to have it append the shareURL after the text. Is that possible? I can't include it in the text itself because then the URL would show up twice, and i cant ONLY put it in the text because then images on facebook are not clickable links

use static image.

Is it possible to use static image in the app instead of loading it from a url/network?

Definitely want to use this component in my app. Thanks for this. :)

Android support

Beginning of thread for android support.

I believe a good approach would be to launch a fragment that overlays the current app and displays some targets to share to.
screenshot_20160107-165824

Location implementation

Hello,

would it be possible to implement location sharing?
Would like to have this feature for an map application.

Kind Regards
Alexander Niebuhr

node Error: Cannot find module 'react-native-activity-view'

I've installed react-native-activity-view in my project with npm i --save react-native-activity-view then when trying to resolve the module with node I get:

~/sources/nuxeo-mobile$ node -e "require.resolve('react-native-activity-view')"
module.js:442
    throw err;
    ^
Error: Cannot find module 'react-native-activity-view'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.resolve (internal/module.js:27:19)
    at [eval]:1:9
    at Object.exports.runInThisContext (vm.js:54:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:541:32)
    at node.js:311:29
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I actually first noticed this using eslint, but in fact the issue occurs at the node level:

~/sources/nuxeo-mobile$ npm run lint

> [email protected] lint /Users/ataillefer/sources/nuxeo-mobile
> node node_modules/eslint/bin/eslint.js src/

/Users/ataillefer/sources/nuxeo-mobile/src/Root.js
  4:26  error  Unable to resolve path to module 'react-native-activity-view'  import/no-unresolved

with import ActivityView from 'react-native-activity-view'; at the top of Root.js.

This happens because node uses the "main" element of package.json: ActivityView to try to find the react-native-activity-view/ActivityView file which doesn't exist.

Usually "main" references an index.js file, that might be a solution if you can manage the iOS vs unsupported Android issue.

Setting "main": "ActivityView.ios.js" in package.json is a temporary workaround.

On our side we used the following workaround in .eslintrc:

'rules': {
  ...
  'import/no-unresolved': [2, { ignore: ['react-native-activity-view'] }],
},

Thanks!

No Wechat sharing option

Hi,

thank you for this component. I can't find Wechat button in the sharing menu, any reason why? (Is it related with UIActivity).

As I understand, it's possible to exclude an application from the list, is it possible to add one?

Thank you!

Support localized interface?

Despite the settings of my phone, the locale of activity view is always shown in English.
Is there a way to add localization for this interface?
Thanks

Is PDF file officially supported ?

I have tried "imageBase64 , imageUrl, url and file" ,
imageBase64 and imageUrl return error for not selecting an image.

url and file both return .text file showing the filepath or the image source code,

I have tried pdf with base64, filepath, external url. All without success and some return me a txt file with the filepath .

Use RCTImageLoader

So we can reuse cache when e.g. you are on a view that already has an image loaded (no need to have a blocking 2s request).

Example implementation (which is async, so we have to change the contents of the method):

if (imageUrl) {
    RCTImageLoader *loader = (RCTImageLoader*)[self.bridge moduleForClass:[RCTImageLoader class]];
    [loader loadImageWithTag:imageUrl callback:^(NSError *error, id imageOrData) {
        UIImage *loadedImage;
        if ([imageOrData isKindOfClass:[NSData class]]) {
            loadedImage = [UIImage imageWithData:imageOrData];
        } else {
            loadedImage = imageOrData;
        }
    }];
}

I am going to submit a PR with that later today, I hope there are no objections against implementing that 💪

merge with react-native-social-share?

Code is very much the same and provides the same feature. It would be awesome if we can merge the two projects.

I was hoping to get react-native-social-share merged into activity-view.

@naoufal What do you think? I can PR.

Crashes on iPads for iOS 8+

Since the new UIPopoverPresentationController is used for presentation, some additional setup needs to be done.

Linking issue

I am using pod and include the package and get the following error:

Undefined symbols for architecture x86_64:
"OBJC_CLASS$_RCTImageLoader", referenced from:
objc-class-ref in libActivityView.a(ActivityView.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Use URI as image path

Hello!

I'm using react-native-view-snapshot + react-native-fs to save a snapshot from my app to internal filesystem, and would like to use this image to share using activity view.

I've tried using the URI path as imageUrl, image, and as file, but no success.

Not sure if useful, but the URI path is:

" /Users/michael/Library/Developer/CoreSimulator/Devices/55B0AAA9-B0F1-4C75-8FAB-49C30DF4803F/data/Containers/Data/Application/86108B1E-8A11-49C9-A41A-0645A7FB0CC1/Library/Caches/snap.png"

Is it possible? Or will I need to convert it to base64?

Transforming issue in android

Hi,

I am facing issue in android when react packager transform modules. RN packager tries to load ActivityView.android.js but it could not load. I am getting following error:
The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false

Body:
{"from":"{ProjectDirectory}\node_modules\react-native-activity-view\ActivityView.android.js","to":"warning","message":"Unable to resolve module warning from {ProjectDirectory}\\node_modules\\react-native-activity-view\\ActivityView.android.js: Module does not exist in the module map or in these directories:\n {ProjectDirectory}\node_modules\n\nThis might be related to https://github.com/facebook/react-native/issues/4968\nTo resolve try the following:\n 1. Clear watchman watches: watchman watch-del-all.\n 2. Delete the node_modules folder: rm -rf node_modules && npm install.\n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start --reset-cache.","name":"UnableToResolveError","type":"UnableToResolveError","errors":[{}]}
onResponse
DevServerHelper.java:332
execute
RealCall.java:126
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1113
run
ThreadPoolExecutor.java:588
run
Thread.java:818

I have done all the steps that is given in error but could not resolve error. RN packager stuck at 99.7% as showing in attached picture. This was working fine with react native version 0.39 and activity view release version 0.2.5. Now I upgraded RN version to 0.42.3 and activity view version 0.2.11 and facing this issue after upgradation.
untitledss

Activity view can't open from modal

I was getting the following error when I was trying to show the activity view from within a modal.

Warning: Attempt to present <UIImagePickerController: 0x7f8cde1afc00> on <UIViewController: 0x7f8cded45ba0> whose view is not in the window hierarchy!

I found a similar issue with another react native module and tried the same solution which worked.

react-native-image-picker/react-native-image-picker#24

I modified ActivityView.m changing line 125 (https://github.com/naoufal/react-native-activity-view/blob/master/ActivityView.m#L125) to the following:

[ctrl.presentedViewController presentViewController:activityView animated:YES completion:nil];

I have no ObjectiveC experience though so while this works for me, not sure if it's the right thing to do.

Thoughts?

Version 0.2.9 + React Native 0.22.2 does not work anymore.

Hi.

Since the latest update the activity view does not show anymore:

const onClickShare = (postDetail) => {
  ActivityView.show({
    text: 'Check out this cool Fashwell post.',
    url: postDetail.detail_url,
    imageUrl: postDetail.post_img_url
  });
};

After downgrading to 0.2.8 it works fine. Any idea why this is happening?

Cheers, Livio!

Share Did Finish Callback

It would be interesting to hook into the Activity View complete to know if they cancelled or sent.

Share 'Wechat' Application not work

Hello, i already installed your library, whatsapp, facebook ... is ok, but wechat application not work, show the unsupport message. i just share a text, no image. thanks for help me to fix

01

02

UIActivityIndicatorView Undefined

undefined is not an object (evaluating 'NativeModules.UIManager.UIActivityIndicatorView.Constants)

React Native 0.5, Activity View 0.2.1

screen shot 2015-06-29 at 11 09 51 am

State of master

Hi!

I recently discovered your module. I've tried to share a file with it, but latest npm package does not include the commit with support of file option.

I've tried install react-native-activity-view from github, but it simply does not do anything. No errors, no activity view.
Is it any work in progress in master branch?

PS:
this code does not add file as attachment, but puts file url as text

[shareObject addObject:file];

I am about to make a PR to fix that, but master does not work, so I am a bit confused about this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.