Giter Site home page Giter Site logo

react-native-openanything's Introduction

react-native-openanything

Open anything in your react-native app.

Supports call, email, text (sms), iMessage (iOS only), Map, PDF, etc.

Installation

React Native >= 0.49

npm install react-native-openanything

General Guide

This library is promise based and each method returns a promise.

    import {Call} from 'react-native-openanything';

    Call('+155555555555').catch(err => console.error(err));

Available Methods

Call a number from your app!

Call(phone, prompt = false)
Prop Description Default
phone A string that represents the phone number to call. Required
prompt If set to true, it will ask the user for permission to call. Only iOS false

Send an email from your app!

Email(to = false, subject = false, body = false, cc = false, bcc = false)
Parameter Description Default
to A value that indicates the recipient e-mail. Can either be string for single recipient or an array for multiple recipients. false optional
subject A string for the subject for the e-mail. false optional
body A string for the body message for the e-mail. false optional
cc Same as to however the recipient(s) will be designated for the cc field. false optional
bcc Same as to however the recipient(s) will be designated for the bcc field. false optional

Note: The default email application will be open even if no parameter is set.


Send an text (sms) from your app!

Text(phone, message = false, autoEncode = true)
Parameter Description Default
phone A string that represents the phone number to call. Required
message A string for the message. false optional
autoEncode If set to true, the method will auto encode the message. true optional

By default this method tries to properly encode the message however in same cases that might not work. If you have trouble just set the autoEncode parameter to false.

Note: If message is not a string, this method will open the default text client regardless.


Open any URL from your app!

Web(url)
Parameter Description Default
url A string that represents the url. Required

Displays a map from your app!

Map(address)
Parameter Description Default
address A string that represents the address. Required

Note: You can either provide an string or an array with latitude and longitude to this method.


Opens a YouTube Video

Youtube(video)
Parameter Description Default
video A string that contains the Youtube video id. Required

Opens Twitter

Twitter(user)
Parameter Description Default
user A string that contains the Twitter User Id that should be open. Required

Opens Facebook

Facebook(user)
Parameter Description Default
user A string that contains the Facebook User Id that should be open. Required

Opens Instagram User, Media, Camera, App, Location and Tag

Instagram(user)
Parameter Description Default
user A string that contains the Instagram User Id that should be open. Required
InstagramMedia(media)
Parameter Description Default
user A string that contains the Instagram Media Id that should be open. Required
InstagramLocation(location)
Parameter Description Default
user A string that contains the Instagram Location Id that should be open. Required
InstagramTag(tag)
Parameter Description Default
user A string that contains the Instagram Tag Id that should be open. Required
InstagramApp()

Opens the Instagram App.

InstagramCamera()

Opens the Instagram Camera.


Only iOS Launch Facetime

Facetime(target, audioOnly = false)
Parameter Description Default
target A string that representing a phone number or a username. Required
audioOnly A boolean value indicating if facetime is an audio call false optional

Low level methods

Note: You should only use these methods if you know what you doing.


Supported - checks if a deep linking URL is supported on the current device.

Supported(url)
Parameter Description Default
url The url to check. Required

Open - opens an deep linking URL.

Open(url)
Parameter Description Default
url The url to open. Required

Launch - Combines Supported and Open

Launch(url)
Parameter Description Default
url The url to verify and open. Required

Issues and how to resolve them

App is not allowed to query scheme

On iOS you might run into this issue. The reaon is that you have to explicit add the requesting query schemes into the pinfo.list variable LSApplicationQueriesSchemes.

e.g. for Facebook you would add fb. Please refer to the example list below for the correct query scheme string:

Target Query Scheme
Facebook fb
Instagram instagram
Twitter twitter
LinkedIn linkedin
WhatsApp whatsapp

Examples

You can either import specific modules:

import { Call, Text, Web, Map, EMail } from 'react-native-openanything';

...

render() {

	<View>
    	<Button onPress={() => Call('+12105551234')}>
        	<Text>Call</Text>
        </Button>
        <Button onPress={() => Text('+12105551234', 'Can you please call me!')}>
        	<Text>Text</Text>
        </Button>
    </View>
}

or import all modules as wildcard:

import * as OpenAnything from 'react-native-openanything';

...

render() {

	<View>
    	<Button onPress={() => OpenAnything.Call('+12105551234')}>
        	<Text>Call</Text>
        </Button>
        <Button onPress={() => OpenAnything.Call('+12105551234', 'Can you please call me!')}>
        	<Text>Text</Text>
        </Button>
        <Button onPress={() => OpenAnything.Email('[email protected]')}>
        	<Text>E-Mail</Text>
        </Button>
        <Button onPress={() => OpenAnything.Web('http://www.google.com')}>
        	<Text>Google Homepage</Text>
        </Button>
        <Button onPress={() => OpenAnything.Map('Google')}>
        	<Text>Google HQ</Text>
        </Button>
    </View>
}

react-native-openanything's People

Contributors

carlosrod-cbqa avatar flyandi avatar wesleyfaveri 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-openanything's Issues

Facebook error

canOpenURL: failed for URL: "fb://profile/MY_FACEBOOK_ID" - error: "This app is not allowed to query for scheme fb"

Also on another subject are there any plans to add linkedin and instagram links handling?

On iOS the mail app opens but cursor sets on first position of mail body

Hello, I like to report an issue that whenever I open the email app via :
Email(to = 'sup..@z...com', subject = 'Query', body = 'lorem ipsum is a dummy text', cc = false, bcc = false)

Current behaviour : the mail app opens but the cursor sets on first position and keyboard opens out. Need to know if this can be changed or not.

Expected : cursor should placed on the end of body, keyboard not opens as in rest of the apps I checked out, their keyboard not opens.

Thanks
prashant

PDF

Can you please add an example how to open a PDF...
Thanks

instagram won't open with on click

i have this piece of code

onPress={() => Instagram('277073967')}

when click i get

[Unhandled promise rejection: ReferenceError: Can't find variable: _]

  • node_modules\react-native-openanything\src\launcher.js:62:11 in LaunchString
  • node_modules\promise\setimmediate\core.js:45:6 in tryCallTwo
  • node_modules\promise\setimmediate\core.js:200:22 in doResolve
  • node_modules\promise\setimmediate\core.js:66:11 in Promise
  • node_modules\react-native-openanything\src\launcher.js:60:21 in LaunchString
  • Screens\kidsAndTeens.js:30:29 in TouchableOpacity.props.onPress
  • node_modules\react-native\Libraries\Components\Touchable\TouchableOpacity.js:174:10 in Pressability$argument_0.onPress
  • node_modules\react-native\Libraries\Pressability\Pressability.js:655:17 in _performTransitionSideEffects
  • node_modules\react-native\Libraries\Pressability\Pressability.js:589:6 in _receiveSignal
  • node_modules\react-native\Libraries\Pressability\Pressability.js:499:8 in responderEventHandlers.onResponderRelease
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:286:4 in invokeGuardedCallbackImpl
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:497:2 in invokeGuardedCallback
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:521:2 in invokeGuardedCallbackAndCatchFirstError
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:683:41 in executeDispatch
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:707:19 in executeDispatchesInOrder
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:872:28 in executeDispatchesAndRelease
  • [native code]:null in forEach
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:851:4 in forEachAccumulated
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:897:20 in runEventsInBatch
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:1069:18 in runExtractedPluginEventsInBatch
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2835:35 in batchedUpdates$argument_0
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:20569:13 in batchedUpdates$1
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2731:29 in batchedUpdates
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2834:16 in _receiveRootNodeIDEvent
  • node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-dev.js:2911:27 in receiveTouches
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:425:19 in __callFunction
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112:6 in __guard$argument_0
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:373:10 in __guard
  • node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:111:4 in callFunctionReturnFlushedQueue
  • [native code]:null in callFunctionReturnFlushedQueue

LinkedIn

Feature for opening LinkedIn app links.

fb://profile/{fbid} does not work.

Hi. Facebook does not open the desired profile page in Android when using the fbid. However, it does work when using the referrer_profile_id.
Using Mark Zuckerberg's official profile page.
https://www.facebook.com/photo.php?fbid=10102454385528521&set=a.743613136151.2308566.4&type=3&source=11&referrer_profile_id=4

I had to manually visit the page, copy the link address and get the value of the referrer_profile_id.
I can only get the fbid from the graph.api and not the other id.

Thanks.

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.