在单个应用程序中反应本机共享 [英] react native share in a single application
本文介绍了在单个应用程序中反应本机共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 react-native 应用程序中,我想与特定应用程序(例如 whatsapp 或短信应用程序)共享一条短信,而无需先与所有社交应用程序进行对话.
In my react-native app, I want to share a text message with a specific application, e.g whatsapp or texting application without having to first land on the dialog with all the social applications.
例如,如果我按下分享按钮并直接调用 whatsapp.
For instance if I press the share button and whatsapp is called directly.
我尝试使用 react-native-share
但它似乎不再起作用了.
I tried using react-native-share
but it seems to not be working anymore.
推荐答案
您可以使用 链接,它为您提供了一个通用界面来与传入和传出的应用程序链接进行交互.
例如:
import React, { Component } from 'react';
import { Linking, Button } from 'react-native';
export class App extends Component {
render() {
return <Button
onPress={() => {
let url = 'whatsapp://send?text=Hola Mundo';
Linking.openURL(url).then((data) => {
console.log('open whatsapp')
}).catch(() => {
console.log('App not installed')
});
}}
title="Whatsapp"
color="#4FBE3C"/>;
}
}
这篇关于在单个应用程序中反应本机共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文