Ama*_*l p 5 android share ios hybrid-mobile-app react-native
我想和大家分享我app从我的安装链接到其他app的设置react native。
我为此使用了react native共享api。
但是使用下面的代码输出只显示消息(下面的代码和屏幕截图)。
const shareAppOptions = {
title: 'App link',
message: 'Please install this app and stay safe',
url: 'https://play.google.com/store/apps/details?id=nic.goi.aarogyasetu&hl=en'
};
Run Code Online (Sandbox Code Playgroud)
有什么问题?,我到处搜索,没有人有合适的例子。
Gau*_*Roy 12
问题是在Android中,你不能指定一些东西作为 url ,但是当你在IOS中做同样的事情时,你会得到链接(检查文档进行交叉验证:rn-share。最好你可以在消息本身,以便两个平台都可以获取它而无需编写双重代码。
就像这样的例子:
import React from 'react';
import { Share, View, Button } from 'react-native';
export default ShareExample = () => {
const onShare = async () => {
try {
const result = await Share.share({
title: 'App link',
message: 'Please install this app and stay safe , AppLink :https://play.google.com/store/apps/details?id=nic.goi.aarogyasetu&hl=en',
url: 'https://play.google.com/store/apps/details?id=nic.goi.aarogyasetu&hl=en'
});
if (result.action === Share.sharedAction) {
if (result.activityType) {
// shared with activity type of result.activityType
} else {
// shared
}
} else if (result.action === Share.dismissedAction) {
// dismissed
}
} catch (error) {
alert(error.message);
}
};
return (
<View style={{ marginTop: 50 }}>
<Button onPress={onShare} title="Share" />
</View>
);
};
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你。如有疑问请放心
我认为您可以通过将网址放在消息部分来共享您的应用程序链接。
message:'https://play.google.com/store/apps/details?id=nic.goi.aarogyasetu&hl=en'
| 归档时间: |
|
| 查看次数: |
11303 次 |
| 最近记录: |